A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: play, then wait (a few seconds) then play etc

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Location
    Toronto Canada
    Posts
    186

    play, then wait (a few seconds) then play etc

    Hi

    It would be great if someone could help me with this:

    instead of having long stretches in my timeline it would be great to have a keyframe with actionscript 2 have the playhead wait a few seconds, then play.

    is there an easy way to have this happen? and can i change the amount it waits on different key frames (3 seconds here, 5 seconds there) ?

    thanks in advance

  2. #2
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    i've never used the function, but check out setTimeout()

    from the help docs:
    Runs a specified function after a specified delay (in milliseconds). The setTimeout() function is similar to the setInterval() function, except that setTimeout() calls the function once and then is automatically deleted.


    if that doesn't work you could probably also use setInterval
    Evolve Designs Interactive Media
    the natural selection

  3. #3
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Flash 6, AS1 and Flash 7, AS2
    Code:
    _global.doPause = function(mc, secs) {
    	mc.stop();
    	var intID = setInterval(goOn, secs * 1000, mc);
    	function goOn(mc) {
    		clearInterval(intID);
    		mc.play();
    	}
    };
    // call the function like this
    doPause(this, 2);
    Flash 8, AS2
    Take a look at setTimeout().

  4. #4
    Senior Member
    Join Date
    Apr 2001
    Location
    Toronto Canada
    Posts
    186
    thanks for taking a look at my post.


    i'm using cs3, actionscript 2 (i'm a designer not a programmer) so i'm not too nimble with the "look into Timeout() thing" looking into it for me means "ok, i saw it, now what".

    so maybe i should phrase the problem a little differently...

    what do you guys do when you want to hold frames in flash movies? do you press F5 like 200 times? or is there a smarter way to do it that you guys use?

  5. #5
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    dawsonk provided the code to use already.

    copy this to the main timeline:

    PHP Code:
    _global.doPause = function(mcsecs) {
        
    mc.stop();
        var 
    intID setInterval(goOnsecs 1000mc);
        function 
    goOn(mc) {
            
    clearInterval(intID);
            
    mc.play();
        }
    }; 
    then on any frame you want a pause put this code on the timeline:
    PHP Code:
    doPause(this2); 
    where 2 is the amount of time in seconds you want it to wait.
    Evolve Designs Interactive Media
    the natural selection

  6. #6
    Senior Member
    Join Date
    Apr 2001
    Location
    Toronto Canada
    Posts
    186
    oh NICE, i thought it was for flash 6 or 7... like he said...

    awesome. thanks dudes. why did you say it was for flash 6 or 7, it works fine for cs3?

  7. #7
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    because for most setTimeout would be easier but it isn't supported in older versions. The code provided is supported in older versions, but it's also coded in as2 so you can use it on cs3 as long as you don't have your actionscript set to as3.

    wow that sounded nerdy
    Evolve Designs Interactive Media
    the natural selection

  8. #8
    Senior Member
    Join Date
    Apr 2001
    Location
    Toronto Canada
    Posts
    186
    lol. thanks for the help EvolveDesigns and dawsonk...

    much appreciated.

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