Sunday, August 24, 2008

Dynamic source of Image control

In order to change the image source dynamically instead of creating multiple image instances, we could make use of [Embed] tag as follows:

[Embed(source="a.png")]
private var _src_a:Class;
[Embed(source="b.png")]
private var _src_b:Class;

_img = new Image ();
if ( ... ) {
_img.source = _src_a;
} else {
_img.source = _src_b;
}

http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000968.html

No comments: