Flash XML Slideshow/Gallery
Hello,
i am relatively new to flash and actionscript 3 but i have been recently making a website and i have got to a stage where one page is pulling in SWF's via an XML document. There are left and right arrows which load up the next/previous SWF. The right arrow works fine, it loads the next one up and then due to some AS3 code when it gets to the end it loops back around. The left arrow goes back a frame until it comes to the beginning and it wont loop to the end. I just cant get that code to work so i was hoping someone could help me with that.
Below is a copy of the code that i am using. I am aware that i need to create the event listener for the arrow and i am fine with that, its just the function to go with it that i am struggling with.
Thanks anyone for any help/advice in advance :-)
var xmlRequest:URLRequest = new URLRequest("swf_files.xml");
var xmlLoader:URLLoader = new URLLoader(xmlRequest);
var imgData:XML;
var imageLoader:Loader;
var rawImage:String;
var imgNum:Number = 0;
var checkSec:Timer = new Timer(100);
var numberOfChildren:Number;
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadedF);
right.addEventListener(MouseEvent.CLICK, nextImgF);
left.addEventListener(MouseEvent.CLICK, "event goes here");
function xmlLoadedF(event:Event):void{
checkSec.start();
checkSec.addEventListener(TimerEvent.TIMER, checker1);
imgData = new XML(event.target.data);
}
function packagedF():void{
checkSec.removeEventListener(TimerEvent.TIMER, checker1);
rawImage = imgData.image[imgNum].imgURL;
numberOfChildren = imgData.*.length();
imageLoader = new Loader;
imageLoader.load(new URLRequest(rawImage));
center_stage.addChild(imageLoader);
}
function checker1(event:TimerEvent):void{
if(imgNum == 0){
packagedF();
}else if(imgNum < numberOfChildren) {
imageLoader.unload();
packagedF();
}else{
imageLoader.unload();
imgNum = 0;
packagedF();
}
}
function nextImgF(event:MouseEvent):void{
checkSec.addEventListener(TimerEvent.TIMER, checker1);
imgNum++;
}