ah, I missed the 2nd version of the code You have to take the loaderMachine(); call out of the loop, call it after the loop. function xmlReady(evt:Event):void { xml=new XML(evt.currentTarget.data); var xmlListUrls:XMLList=new XMLList(xml.image.url.text()); var xmlListNames:XMLList=new XMLList(xml.image.name.text()); var xmlListDescs:XMLList=new XMLList(xml.image.description.text()); for (var g:Number = 0; g < xmlListNames.length(); g++) { imagePack.push({name:xmlListNames ,url:xmlListUrls ,desc:xmlListDescs }); } // start loading images loaderMachine(); } You're overwriting you loader instance each time you load an image, that's not good if you want it to stick around (display each loaded image). So in the method, create a local Loader instance and add it to the Array stack. Don't start the enterFrame event handler until all images are loaded. You can do so in the imageReady() event handler (check if counter equals array length). Don't add event listeners in the enterFrame event handler, you're adding them over and over again. So remove these from entFrm() imageIcons .addEventListener(MouseEvent.MOUSE_OVER,btn_mouse); imageIcons .addEventListener(MouseEvent.MOUSE_OUT,btn_mouse); Don't use Event.target (unless you know what you're doing), use currentTarget instead. function imageReady(evt:Event):void { var loader:Loader = (event.currentTarget as LoaderInfo).loader; loader.addEventListener(MouseEvent.MOUSE_OVER, btn_mouse); loader.addEventListener(MouseEvent.MOUSE_OUT, btn_mouse); addChild((loader); count++; if (count<imagePack.length) { loaderMachine(); }else{ addEventListener(Event.ENTERFRAME, entFrm); }} Don't use Array.length in a loop condition, as this will check the lenght with each iteration, slowing down the loop. Set it to a local variable once and use that as the loop condition. var len:uint = imageIcons.length; for(var i:uint=0; i<len; i++) {} Last but not least, you're probably better off using a tween engine rather than an enterFrame event to move things around. Look into TweenLite. http://blog.greensock.com/tweenlite/ It now looks like the enterFrame event continues untill you roll over one of the buttons? If so, that can't be good.. function loaderMachine():void { var loader:Loader = new Loader(); loader.load(new URLRequest(imagePack[count].url)); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageReady); imageIcons.push(loader); }
... View more