I have a slideshow that I want to loop. What it does is load an xml file with the locations of the images. It uses an int variable to progress from one image to the next. What i need it to do is when it gets to the end of the list, to go back to the beginning, essentially setting imgNum back to 0. So I figured a simple if/else statement would do the trick, but I just keep getting a “TypeError: Error #1010: A term is undefined and has no properties.” no matter what I try. The nextImage function is triggered via the movieclip that runs once the loader is done and has been added as a child to a placeholder inside said movieclip. Here’s the code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var imageLoader:Loader;
var imgNum:int=0;
var xml:XML;
var rawImage:String;
var xmlList:XMLList
var xmlLoader:URLLoader = new URLLoader();
var numberOfChildren:Number;
xmlLoader.load(new URLRequest("mainSlide.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
imageMaster_mc.addEventListener("movieClipDone", nextImage);
function xmlLoaded(event:Event):void
{
xml = XML(event.target.data);
numberOfChildren=xml.*.length();
packagedF(null);
}
function packagedF(event:Event):void
{
rawImage=xml.image[imgNum].imgURL;
imageLoader = new Loader();
imageLoader.load(new URLRequest(rawImage));
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, waitForLoad);
function waitForLoad(event:Event):void
{
imageMaster_mc.imageMaster_anim.addChild(imageLoader);
imageLoader.y = -50;
imageMaster_mc.gotoAndPlay(2);
}
}
function nextImage(event:Event):void
{
if (imgNum < numberOfChildren)
{
imgNum++
packagedF(null);
}else
{
imgNum = 0;
packagedF(null);
}
}
Maybe an array would be the better way to go about this? I haven’t used arrays much so if this is the solution, please be thorough when you explain it. Thanks in advance for any help!