A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Delay

  1. #1
    Junior Member
    Join Date
    Apr 2001
    Posts
    16

    Really need help with this.

    I want to be able to put a delay on a actiionscrip. give you an example:

    on (rollOver) {
    text="Good Morning.";
    (DELAY PART for 20 sec.)
    text2="and Good Afternon";
    }

    i'm open to any ideas. thanks...
    M1tank

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Posts
    475
    hm.... a 20 second delay without making the flash player complain about a "slowing down" loop...

    my idea is to put a new empty MC with 12 frames on stage. Now loop the MC between 10 frames, where no actions are in. when the movie ran the loop 20 times about 20 seconds have passed. Now the MC can set the text2 variable to "Good evening". code:

    Frame 1:
    cycles = 0;
    play();

    Frame 12:
    cycles++;
    gotoAndPlay(2);
    if (cycles == 20)
    text2 = "Good Evening";

    using the first idea would need resructuring of your movie... but as i mentioned above the 2nd idea might make flash player think he's super intelligent:

    on (rollOver) {
    text="Good Morning.";
    // delaycode
    start = getTimer();
    while ((getTimer() - start) < 20000);
    // end delaycode
    text2="and Good Afternon";
    }

    here the while statement checks infinitely how many milliseconds have passed since the rollovera and stops when 20 seconds are passed. and this might be a problem...

    Anybody having another idea for delay? I'm quite interested in this stuff too.
    Yours
    HTD

  3. #3
    Hack
    Join Date
    Mar 2000
    Location
    Madison, WI
    Posts
    1,753
    on (rollOver) {
    text="Good Morning.";
    starttime=getTimer();
    while getTimer()-starttime<20000 {
    }
    text2="and Good Afternon";
    }

    The problem with this is that when any loop continues for more than 15 seconds, Flash assumes there's a problem and throws up a prompt asking the user if he/she wants to quit the script. So I wouldn't use this to pause more than 5 or 10 seconds.

    For longer pauses, you're going to have to do something like this:

    on (rollOver) {
    gotoAndPlay("label")
    }

    Frame "label":

    text1="Good Morning";
    starttime=getTimer();

    Frame "label"+2:

    if getTimer()-starttime<20000 {
    gotoAndPlay(_currentframe-1);
    }else{
    text2="and Good Afternoon";
    }



  4. #4
    Junior Member
    Join Date
    Apr 2001
    Posts
    16

    Smile Thanks

    Thanks for the help, i'm sure one of the ideas will work best for me, and I'll have to let you know if it works.

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