开发者

How to load a image from directory using flash?

I want to click on a button and then choose a image to load (browsing directories) and use it as background开发者_运维知识库.

Is that possible using flash and actionscript 3?


Use Loader class to do this:

function LoadImage(imageURL:String) {
    var imageLoader:Loader = new Loader();
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, ImageLoaded); // event listener which is fired when loading is complete
    imageLoader.load(new URLRequest(imageURL));
}

function ImageLoaded(e:Event) {
    e.target.loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, ImageLoaded);
    this.addChild(e.target.loader.content); // loaded content is stored in e.target.loader.content variable
}

But, if you want to load image from local directory you can use FileReference class to do that, read the documentation for more details.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html


Yes it is, use Loader class... read here for how to use it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜