Im making an app that ratates images in seperate MCs from seperate arrays. The problem seems to be in the nextImage function, where the currentImage variable doesnt seem to advance, leaving the first image in the array to repeat on the cycle. It works fine when I trigger the function independently, but not when I trigger it twice at the same time. My guess is that maybe the variable is getting rewritten back and for by each instance. Thanks in advance.
var pic1Container:Sprite = new Sprite;
var pic2Container:Sprite = new Sprite;
var firstScreenArray:Array = new Array(ban1, ban11)
var secondScreenArray:Array = new Array(ban2, ban22)
var currentImage1:uint = 0;
var currentImage2:uint = 0;
var timerSpeed:uint = 2000;
var imageTimer:Timer = new Timer(timerSpeed);
imageTimer.addEventListener(TimerEvent.TIMER, imageTimerStart);
addChild(pic1Container);
addChild(pic2Container);
imageTimer.start();
////////////////////////////////////////////////////////////////////////////////////
//timer function that initiates image rotation function
function imageTimerStart(e:TimerEvent){
nextImage(firstLoaderArray, pic1Container, currentImage1);
nextImage(secondLoaderArray, pic2Container, currentImage2);
}
///////////////////////////////////////////////////////////////////////////////////
//image rotation
function nextImage(loArray, picContainer, currentImage){
picContainer.addChild(loArray[currentImage]);
loArray[currentImage].alpha = 0;
Tweener.addTween(loArray[currentImage], {alpha: 1, time:1.5, transition:"easeOutQuad"});
if (currentImage < loArray.length -1){
currentImage++;
} else {
currentImage = 0;
}
}