/ Published in: ActionScript 3
A simple way to load images into different holders. Not an end-all solution but its the basics.
Expand |
Embed | Plain Text
loadImage("myImage.jpg",holder1); function loadImage(clip:String, holder:MovieClip):void { removeChildren(holder); var imageLoader:Loader = new Loader(); var imageURL:String = clip var imageURLReq:URLRequest = new URLRequest(imageURL); holder.addChild(imageLoader); trace("loading "+imageURL); imageLoader.load(imageURLReq); imageLoader.contentLoaderInfo.addEventListener(Event.INIT, imageLoaded); imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageProgress); } function imageProgress (evt:ProgressEvent):void { //trace(Math.round((evt.bytesLoaded / evt.bytesTotal)*100)); } function imageLoaded(evt:Event):void { //var targetLoader:Loader = Loader(evt.target.loader); //trace("complete"); } function removeChildren (container:MovieClip):void { while (container.numChildren) { container.removeChildAt (0); } }
You need to login to post a comment.
