A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: simple AS driven timer

  1. #1
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215

    simple AS driven timer

    hey dudes,

    i just wanted to know if there is such
    a thing as a "simple AS made timer"?

    cause i would really like
    to know how one is made


    anyhoo, tnx a bunch!
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  2. #2
    Junior Member
    Join Date
    Jan 2003
    Posts
    18
    Yes... and No...

    There is a simple function called setInterval(function, interval) which repeats a call to a function every... well, however often you want, down to once every millisecond.

    If you wanted a timer you could just call a count function every 1000 milliseconds (1 second) and increment a variable. Then when you want to stop timing, just get the value of your counting variable and remove the counter with clearInterval().

    Here is an example which will show you what I mean. Just paste this into a new flash document and test the movie:

    var myCount:Number=0;
    var myInterval:Number = setInterval(thisTimer,1000);

    function thisTimer():Void {
    trace(myCount);
    myCount++;
    }

    Have fun,

    And so much better than using onEnterFrame()


  3. #3
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215
    lol, thnx dude!

    oh i believe the script would be put
    in a frame rather a movieclip right?
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  4. #4
    Junior Member
    Join Date
    Jan 2003
    Posts
    18
    spot on... correct... well done.

    7 cookies for you! mmm... cookies... sorry, I ate the other 3!


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