trying to make a dead simple slideshow. The code I got works but it does not load the images in order of how they are named (i.e image0.jpg, image1.jpg, etc.)
import fl.transitions.easing.*;
import fl.transitions.*;
var imgArray:Array = new Array();
var loader:Loader;
var timer:Timer = new Timer(5000);
var count:int = 0;
var numImages:int = 5;
for(var i:Number=0; i<numImages; i++){
loader = new Loader();
loader.load(new URLRequest("factImages/image"+i+".jpg"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, pushImage);
}
function pushImage(e:Event):void{
var holder:MovieClip = new MovieClip();
holder.addChild(e.target.content);
imgArray.push(holder);
if (imgArray.length == 5){
startShow();
}
}
function startShow():void{
//add initial image
addChild(imgArray[0]);
inTrans(imgArray[0]);
count = 1;
timer.addEventListener(TimerEvent.TIMER, slideShow);
timer.start();
}
function slideShow(event:TimerEvent):void{
addChild(imgArray[count]);
inTrans(imgArray[count]);
count++;
//reset counter
if(count == 5){count = 0};
if(numChildren > 2){
removeChild(getChildAt(0));
}
}
function inTrans(mc:MovieClip):void{
var myTransitionManager:TransitionManager = new TransitionManager(mc);
myTransitionManager.startTransition({type:Wipe, direction:Transition.IN, duration:2, easing:Strong.easeOut});
var fadeIn:TransitionManager = new TransitionManager(mc);
fadeIn.startTransition({type:Fade, direction:Transition.IN, duration:3, easing:Strong.easeOut});
}
any clues on how to force the images to be loaded by their filename order?
I do not want to use XML for a 5 image slideshow.
I tried renaming the images but the order still gets jumbled (i.e image3, image1, image4, image2, image0)