
1) create an XML file that has the URL of the external images contained in <IMAGE> tags.
2) upon a button click, load said XML file, and store xml_File.IMAGE as an XMLList (i.e. photoAlbum = XMLList(myXML.IMAGE))
3) using a loop that pays attention to photoBox.length(), sequentially load each URL and add them as children to a greater container (photoBox).
Here’s the code:
// create generic URL loader for XML var xmlLDR:URLLoader = new URLLoader(); // create a container for image URL’s var photoAlbum:XMLList = new XMLList(); // create a marker to keep track of total files in gallery var galLength:int; // pCounter is independent counter used for progress bar var pCounter:int = 0; // photoBox is the container for the loaded photos var photoBox:MovieClip = new MovieClip(); stage.addChild(photoBox); function loadXML():void { xmlLDR.removeEventListener(Event.COMPLETE, loadXML); bar_cont.visible = true; var tempXML:XML = XML(e.target.data); photoAlbum = XMLList(tempXML.IMAGE); galLength = photoAlbum.length(); for (var i:int = 0; i < galLength; i++) { // trace(photoAlbum[i]); var photoLDR:Loader = new Loader(); photoLDR.load(new URLRequest(photoAlbum[i])); photoLDR.contentLoaderInfo.addEventListener(Event.COMPLETE, loadPhotos); // photoLDR.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressBar); } // trace("I"); } // skip further down function loadPhotos(e:Event):void { // create a temp var that’ll be passed onto photoBox var tempPhoto:Loader = Loader(e.target.loader); // uniquely name photos based on pCounter tempPhoto.name = pCounter.toString(); // keep all images invisible until blinder has been drawn tempPhoto.visible = false; photoBox.addChild(tempPhoto); // display (# loaded / # total) textCounter.text = “( “+(pCounter+1)+” / “+galLength+” )”; // conditionally incriment; if all are loaded, drawBlinder / fade out bar /* if ( ( pCounter + 1 ) != galLength) { pCounter++; } else { var fadeOutProgBar:Tween = new Tween(bar_cont, "alpha", Strong.easeInOut, 1, 0, 1.5, true); fadeOutProgBar.addEventListener(TweenEvent.MOTION_FINISH, removeBar); trace("three"); } */ // trace("II"); } // call loadXML loadXML();
I just don’t understand why my images are being loaded out of order…
Thanks,
Steven
If you would like to make a comment, please fill out the form below.
Recent Comments