Comparison: Importing an image using ActionScript 2 and 3
If you are going to develop flash based content using AS3, you should know it takes a bit more work to do simple things. For example, say for inistance you want to load an image into a movie clip called “imgHold_mc” using ActionScript 2, you could use the following code:
function loadImage() {
imgHold_mc.loadMovie(imgUrl);
}
loadImage();-or-
var url:String = “imgUrl”;
function loadImage(link:String){
imgHold.loadMovie(link);
}
loadImage(url);
If you wanted to do the same thing but using ActionScript 3, you would need to use the code bellow:
var imageLoader:Loader;
function loadImage(url:String):void {
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
loadImage(imgUrl);
function imageLoaded(e:Event):void {
imgHold_mc.addChild(imageLoader);
}-or-
var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest(url));
imgHold_mc.addChild(imageLoader);thanks Luis
![]()
About this entry
You’re currently reading “Comparison: Importing an image using ActionScript 2 and 3,” an entry on homer gaines
- Published:
- 07.19.08 / 3pm
- Category:
- ActionScript 2.0, ActionScript 3.0, Flash
No comments
Jump to comment form | comments rss [?] | trackback uri [?]