Hey everybooody,
In this example, I’m trying to programmatically fade-in the alpha of menu items created from xml data. Using the tween object, I’m trying to start the next tween once the first or previous tween has finished.
Clearly in my attempt below, the “if” statement isn’t cutting it because it’s not waiting for the tween to be finished.
Using the oListener.onMotionFinished method, I tried using a Boolean to return true when finished, and then to start the next tween. But clearly I haven’t figured out the proper control flow for this.
I also tried a ‘do while’ statement, attempting to creating a waiting-loop until the bCheck returned true, but that just created a series of open loops, and crashed the program.
The big problem here is that I’m trying to figure out how to do this while looping through an array of menu items, so that I triggure the fade in of each menu item…
Has anyone had experience with this? Thanks!!!
Here’s what I was trying to do:
function fadein_menu() {[INDENT] var bCheck:Boolean = false;
var oListener:Object = new Object();
oListener.onMotionFinished = function(twObject:Tween):Void {
bCheck=true;
};
for (var i = 0; i<totalMenuItems; i++) {[INDENT]if (i==0) {[INDENT]var twMenuAlpha:Tween = new Tween(menuitems*, “_alpha”, Strong.easeIn, 0, 100, 3, true);
twMenuAlpha.addListener(oListener);
[/INDENT]} else if (i>0) {[INDENT]if (bCheck==true) {[INDENT]bCheck=false;
var twMenuAlpha:Tween = new Tween(menuitems*, “_alpha”, Strong.easeIn, 0, 100, 12, true);
twMenuAlpha.addListener(oListener);
[/INDENT]};
[/INDENT]};
[/INDENT]};
[/INDENT]};