dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Delay a Loop?

  1. #1
    Senior Member
    Join Date
    Feb 2008
    Posts
    126

    Delay a Loop?

    I have a loop that creates MCs on the stage in a grid, my problem is it loops through instantly, is there anyway to put a pause in so that each movie clip is added to the stage say every second?

    Thanks

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    This is actually the first point that most AS3 animation books bring up all of your code needs to finish for a frame before the next one will render. The basic message is that loops don't really work for tweening or transitions over time.

    The solution is either an event (like EnterFrame) or a custom Timer...for once every second here's how you'd set that up:

    PHP Code:
    //  new timer, fires every 1000 milliseconds
    var t:Timer = new Timer(1000);

    //  every timer-tick, call addMC();
    t.addEventListener(TimerEvent.TIMERaddMC);  

    //  start the timer
    t.start();


    function 
    addMC(e:TimerEvent):void{
        
    addChild(new MovieClip());
        
    // ...    


  3. #3
    Junior Member
    Join Date
    May 2015
    Posts
    3
    I have a banner ad that has 3 loops and stops, problem is it loops through instantly, is there anyway to put a delay in-between the loops so if someone wants to click on the button they can?

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center