Flash Timer (actionscript question)

Discussion in 'Web Design and Development' started by ac6789, Nov 25, 2007.

  1. ac6789 macrumors member

    Joined:
    Jun 28, 2007
    #1
    Question for those ActionScript experts:

    Can anyone give me or lead me toward a script that will hold on a certain frame for a defined amount of time before moving on to the next frame?

    I've been searching for the answer for this particular question for a while and nothing I've seen really accomplishes this.

    For the moment, if I needed something to stay on screen for 10 seconds (as an example) I've been putting in 120 frames (@ 12 frames per second).

    If anyone used Director before, I used to be able to do this by telling the stage to hold on a frame for a certain amount of "ticks" before moving on, is there something similar in Flash?

    Thanks in advance!
     
  2. builder macrumors newbie

    Joined:
    Jan 30, 2007
    #2
    Use the setInterval() command. If you are unfamiliar with it, it basically runs a function continously to whatever time interval you specificy until you clear it with clearInterval().

    The following code will would be in the root timeline. It clears the interval first so you don't need to clear it on your own.

    stop(); //Stop on the frame you want

    var myInterval = setInterval(function () {
    clearInterval(myInterval); // Clears the interval
    play();
    }, 12000); //Hold time in milliseconds. Will play the _root timeline after 12 sec


    Cheers
     
  3. ac6789 thread starter macrumors member

    Joined:
    Jun 28, 2007
    #3
    builder: thanks for the code! going to try this out tonight.
     
  4. mbwmbwmbw macrumors newbie

    Joined:
    Feb 25, 2009
    #4
    hi noticed this code while gogle-ing

    this works well thanks for the help.

    Im wondering if you might know how to clear the interval of an swf that is being loaded into a main movie(using loadMovie - into an empty movie clip)

    for some reason when each Movie loads into the main empty movie clip, it seems to speed up the frame rate or something to the point where my movie is running at 120 FPS?!! its kinda funny, but i cant laugh at it anymore!

    can i somehow set the time back to 0(normal) or clear the interval for each movie, every time it loads?

    thanks a million for any tips you may have
    cheers
     

Share This Page