dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Pausing Actionscript in one frame

  1. #1
    Senior Member
    Join Date
    Jan 2001
    Posts
    105

    Pausing Actionscript in one frame

    OK,

    I've searched but couldn't find the answer to pausing actionscript in one frame.

    Here's the scenario:
    variable1 = 5000;
    variable2 = 1000;
    _root.pause(1000);
    //pause this script for one second then continue with rest of script
    variable3 = "Sam";

    I just need to pause for one second (hopefully using a function) for a specified amount of time. Then be able to assign variable3.

    I need to do this all in one frame. Is it possible to just pause a script for a certain amount of time?

    Thanks.
    Mario Cascio
    Webpromotion, Inc.
    http://www.webpromotion.com

    Royalty Free 3D Flash Animation
    http://www.webpromotion.com/fp01.html

  2. #2
    Flash Initiate StuartW's Avatar
    Join Date
    Jul 2000
    Location
    The Metaverse
    Posts
    504
    Check out Senoculars post on setInterval stuff for how to do time based stuff in flash

    http://www.flashkit.com/board/showth...hreadid=419620

  3. #3
    immoralator
    Join Date
    Dec 2001
    Location
    UK
    Posts
    270
    you want to use setInterval(); for this, basically lets you iterate functions at a specified interval until you cancel it. if you set a call to the setInterval function like this:
    Code:
    yourInterval = setInterval(yourFunction, 1000);
    then have your following code ou'd like to run after the 1 second pause in a function called "yourFunction", and cancel the setInterval like so:
    Code:
    yourFunction = function() {
        //do something
        clearInterval(yourInterval);
    };
    there might be errors in the code, I've just written off the top of my head, shouldn't be hard to alter though. i hope that makes sense!

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    105
    Hey guys,

    SetInterval seems to do it's own thing.

    It doesn't appear to allow me to create a loop and then continue on with the same script in the same frame unless I'm missing something.

    In this example:
    Here's the scenario:
    variable1 = 5000;
    variable2 = 1000;
    _root.pause(1000);
    //pause this script for one second then continue with rest of script
    variable3 = "Sam";

    What would the function look like to actually delay variable3 from being assigned until after a pause?
    Mario Cascio
    Webpromotion, Inc.
    http://www.webpromotion.com

    Royalty Free 3D Flash Animation
    http://www.webpromotion.com/fp01.html

  5. #5
    Flash Initiate StuartW's Avatar
    Join Date
    Jul 2000
    Location
    The Metaverse
    Posts
    504
    Off the top of my head, have you tried placing the code in a function:
    Code:
    //Code before the pause
    yourInterval = setInterval(yourFunction, 1000);
    
    yourFunction = function() {
        //rest of your code
        clearInterval(yourInterval);
    };
    Of course there are drawbacks like remebering the path to your variables, so they still work from within the function.

    Just a thought, anyway.

    Stu

  6. #6
    Junior Member
    Join Date
    Mar 2003
    Posts
    6
    setInverval brakes your code. what can you do if you need to
    pause 3 or more times? they should add a pause/delay function to actionscript

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