Hi all, I think removeChild() is the most confusing thing in my life at the moment when it really shouldnt be.
I’m dynamically adding a set of mc’s on the stage, im tweening them from alpha 0 to 1 with tweenlite, I then have a button to remove the items in reverse, but for some reason I can seem to get my head around tweening them back to alpha 0 in reverse order.
I can remove them from the stage with removeChildAt(0), but I would like the animation. Any one have any solutions for this.
I have attached the code and a test file =]
Thank you
import gs.TweenLite;
import gs.easing.*;
var boxCount:int = 6; // Set how many boxes are needed
var _box : box_mc ; // declare the new box_mc
initMenu(); // Call the function
function initMenu()
{
// Loop through the boxCount to create the MC's
for( var i:uint = 0 ; i < boxCount ; i++ )
{
_box = new box_mc; // declare the box
_box.y = 40; // Set y positions
_box.x = 40 + ( i * 20 ); // Set x positions
_box.alpha = 0; // Set the alpha for the box to be 0
TweenLite.to( _box , .5, { alpha : 1 , delay : i /2 }); // Tween the boxes from 0 to 1, with a delay to stagger them
_box.name = i.toString(); // Give the box a unique name
stage.addChildAt(_box , 0); // Add the box to the stage
}
}
remove_btn.addEventListener( MouseEvent.CLICK , removeMenu );
function removeMenu( $event : MouseEvent )
{
for ( var a:uint = 0 ; a < boxCount ; a ++ )
{
TweenLite.to( _box , .5, { alpha : 0 , delay : a / 2 }); // Tween the box to 0, ( THIS DOESNT WORK)
stage.removeChildAt(0); // Remove the children
}
}