user1212216
user1212216

Reputation: 41

time delay in a loop

How to make time delay in a loop

when I write

containers_array[i].scaleX=0.01;
containers_array[i].scaleY=0.01;

and then

Tweener.addTween(containers_array[i], {scaleX:1,scaleY:1, time:1, transition:"easeOutElastic"});    

it works quite good. But I want every containers_array[i] to be added one after another. I don't have them scaled to 100%, they remain being 1%, just like little dots on the screen when I write down:

 var myTimer:Timer = new Timer(1000, sozler_random_array.length);
            myTimer.addEventListener(TimerEvent.TIMER, addButtonsTween);
            myTimer.start();

function addButtonsTween():void{
Tweener.addTween(sozC_array[i], {alpha:1,scaleX:1,scaleY:1, time:1, transition:"easeOutElastic"});  
}

Thank you in advance

Upvotes: 1

Views: 1477

Answers (2)

Michael
Michael

Reputation: 3871

You're just about there. You just need to add and increment a counter on each timer interval:

var i:int = 0;

var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(TimerEvent.TIMER, addButtonsTween);
myTimer.start();

function addButtonsTween( event:TimerEvent ):void
{
    if (i >= containers_array.length) 
    {
        myTimer.stop();
    }
    else
    {
        Tweener.addTween(containers_array[i], {alpha:1,scaleX:1,scaleY:1, time:1, transition:"easeOutElastic"});  
        i++;
    }
}

Upvotes: 1

Rukshan Dangalla
Rukshan Dangalla

Reputation: 2590

Argument missing.

Try to pass evt:TimerEvent to the addButtonsTween

function addButtonsTween(evt:TimerEvent):void { }

Upvotes: 0

Related Questions