Changing Spark TextArea text highlight color

We have two properties, which should set color for us

focusedTextSelectionColor
unfocusedTextSelectionColor

After setting them you will notice, that highlight color haven’t changed.
But those properties works for spark RichEditableText, which is actually a base for TextArea.
So you need to create custom TextAreaSkin and modify it a bit.

Find:

<s:RichEditableText id="textDisplay" heightInLines="10"
widthInChars="15" />

And add properties like this:

<s:RichEditableText id="textDisplay" heightInLines="10"
widthInChars="15" focusedTextSelectionColor="0x00b4ff" unfocusedTextSelectionColor="0x00b4ff"/>

That’s it!
Now apply newly created skin to you Spark TextArea!

Posted in as3, flex, spark | Leave a comment

Facebook invite friend to application using JavaScript and FBML

In one of latest projects there was a need to embed facebook application invite to third-party blog, hosted on different from application domain.

After a little digging into facebook docs I came with full client-side solution.
Soluton is based on Facebook JavaScript SDK and uses FBML to display invite form. Continue reading

Posted in facebook | Tagged , , , , | 2 Comments

Flex4 Zero UIComponent width and height

In flex 4 you are not allowed to directly addChild Sprite or MovieClip to application and we often use technique of wraping it in UIComponent. Like this:

var sprite:Sprite = new Sprite();
var uic:UIComponent = new UIComponent();
var uic.addChild(sprite);

addElement(uic);

One thing you must know about this solution:
UIComponent by default does not calculate size based on its children. So width and height are equal to zero. This leads to other problems, like parent element wrong sizing or scrollbars issues (they do not appear, because content size = 0).

Solutions:
1. You may want to extend UIComponent and implement measure() method.
2. Manually set UIComponent width and height based on it’s content size.

Posted in as3, flex | Tagged , , | 3 Comments

Is ajax request function on php

This simple php function return true, if request to server is AJAX request.
So you can return different content on the same request URL for AJAX and regular requests.

function is_ajax_request() {
	return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));
}
Posted in php | Tagged , | 2 Comments

Animated GIFs in as3/flex

There is no native support for GIF animation in as3/flex.

You can play and create animated GIF with as3 using this lib:
http://code.google.com/p/as3gif/

Here is a simple example how to load and play animated GIF (flex 4):

	var player:GIFPlayer = new GIFPlayer();
	player.load( new URLRequest("images/animation.gif") );

	var uic:UIComponent = new UIComponent();
	uic.addChild(player);

	addElement(uic);

For more examples and docs – visit project home page.

Posted in as3, flex | Tagged , , | Leave a comment

AS3 Printing MovieClip with auto scaling and rotating based on page orientation

There are a lot of articles about how to print something on flash, with simple PrintJob examples.

But when you want to print something, first of all you want to fit content correctly on page. So you may need to scale and rotate MovieClip before printing. Continue reading

Posted in as3, flex | Tagged , , , | Leave a comment