5 Replies Latest reply on Jan 13, 2008 12:08 PM by gandalf458

    timeout function

    gandalf458 Level 1
      Can anyone tell me what the actionscript equivalents of the javascript setTimeout and clearTimeout methods are please?

      Thanks G :)
        • 1. Re: timeout function
          niki tsanov Level 1
          You can use setTimeout to call function for some time.If you want some web site open after 1 sec you can do like this..For example
          function open(url:String)
          This script open new page after 1 sec.If you want to remove the current timeout you must make like variable.
          var myTime=setTimeout(open,1000,"www.google.bg");
          • 2. Re: timeout function
            gandalf458 Level 1
            Thanks. It looks like actionscript is very similar to javascript...
            • 3. Re: timeout function
              gandalf458 Level 1
              I guess I'm missing something. I want to start a counter going once a Start button is pressed until a Stop button is pressed. Obviously my code (attached) won't do that, it will only increment by one second every time Start is pressed. But I've tried putting the setTimeout within a while loop but it doesn't seem to wait for a second before increasing the timer...
              • 4. Re: timeout function
                niki tsanov Level 1
                So when i need to call some function for more times i use setInterval and clearInterval try with this one i test it work good.And also good information setTimout in flash call just the function once after some time and setInterval call the function many times after some interval :)

                function startIt() {
                timer = setInterval(stopwatch,1000);
                function stopIt() {
                • 5. Re: timeout function
                  gandalf458 Level 1
                  Brilliant. Thanks!

                  G :)