I am creating circle shapes with timer (currently with 40 ms delay) so every second it creates 25 circles, it then tweens few of their properties.
I have left just the alpha which is important (for simplicity) .
On the complete of each tween it tweens each circle’s alpha back to 0, and then removes each circle from the stage.
so after I stop the timer, i can still see 20/30 circles on the stage for about a second until they dissaper.
I wanted to push those circles in an array so that when I stop the timer, I put all visible circle’s alpha to 0, or just remove them all together, so that they **immediatelly **disappear from stage.
but I also need to remove those circles from array which have already disappeared, so that I always have **only **visible circles in an array. (not million of them)
(notice that tween time is math.random for each circle)
how could i remove them from an array in the same timer event?
function createCircles(e:TimerEvent):void {
var circle:Shape = new Shape();
circle.graphics.beginFill(0x000000);
circle.graphics.drawCircle(0, 0, _startRadius);
circle.graphics.endFill();
circle.alpha = 0;
TweenMax.to(circle, 1, {alpha: Math.random() + 0.2, onComplete: reverseCircle, onCompleteParams:[circle]});
addChild(circle);
** _visibleCirclesArr.push(circle);//pushing them in**
}
function reverseCircle(circle:Shape):void {
TweenMax.to(circle, Math.random() + 0.2, {alpha: 0, onComplete: removeCircle, onCompleteParams:[circle]});
}
function removeCircle(circle:Shape):void {
removeChild(circle);
circle = null;
}