开发者

How to set the backgroundImage in mxml at run time?

public var log_img:Class;

[Embed(source="../images/logo.jpg")]

Which is used this way:

<monitor:MonitorDisplay backgroundImage="{ log_img }"/>

The above will Embed the image into the swf,but I want the image to be loaded from the current website,like

<img 开发者_JAVA百科src="/images/logo.jpg" />

How to do this?

I tried this but doesn't work:

[source="http://domain.name/images/logo.jpg"]


use the Loader class.

a simple example:

var loader:Loader = new Loader();
loader.load(new URLRequest("images/logo.jpg"));
addChild(loader);


I you want to load dynamically an image, you should look at the Loader class.

For example :

var imageLoader : Loader = new Loader();
imageLoader.load(new URLRequest("http://farm4.static.flickr.com/3575/3293166516_de2cd751fc.jpg"));
addChild(imageLoader);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜