I’m writing a Think Fast program to teach myself Actionscript, and running into a problem. I’ve written a function to get 3 bars to tween in, one after the other. This is working well, except due to the nature of a think fast game, sometimes time expires while the tweens are still running, and everything gets all gummed up.
Since the tweens need to happen one after the other, I call them inside a function, which means, as far as I understand it, that their variables aren’t accessible by other functions. Any advice for figuring out how to stop tweens inside a different function if the tweens are still running? Or am I just doing it all wrong?
Here’s the tween code
function questionTween()
{
next_b.mouseEnabled = false;
next_b.visible = false;
shade1.x = originX;
shade2.x = originX;
shade3.x = originX;
sndChannelAlive = sndWhoosh.play();
var shade1Tween:Tween = new Tween(shade1,"x",Strong.easeOut,originX,233,tweenSpeed,true);
shade1Tween.addEventListener("motionFinish", finishedTween1);
function finishedTween1(event:Event):void
{
shade1Tween.removeEventListener("motionFinish", finishedTween1);
sndChannelAlive = sndWhoosh.play();
var shade2Tween:Tween = new Tween(shade2,"x",Strong.easeOut,originX,233,tweenSpeed,true);
shade2Tween.addEventListener("motionFinish", finishedTween2);
function finishedTween2(event:Event):void
{
shade2Tween.removeEventListener("motionFinish", finishedTween2);
var shade3Tween:Tween = new Tween(shade3,"x",Strong.easeOut,originX,233,tweenSpeed,true);
shade3Tween.addEventListener("motionFinish", finishedTween3);
sndChannelAlive = sndWhoosh.play();
function finishedTween3(event:Event):void
{
shade3Tween.removeEventListener("motionFinish", finishedTween3);
timetxt.visible = true;
enable_disable(1);
fl_CountDownTimerInstance.start();
if (difficultyLevel == 5)
{
}
else
{
next_b.visible = true;
next_b.mouseEnabled = true;
}
}
}
}
}