dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: timer

  1. #1
    Senior Member
    Join Date
    May 2001
    Posts
    140
    Hi all

    I have this action placed on button from 1 to 8
    on(press){
    capture.n = 1;
    }
    To
    on(press){
    capture.n = 8;
    }

    How do I build a timer that calls a function every 3 seconds. from 1 to 8 on clipevent?

    thanks
    PilotX

  2. #2
    Junior Member
    Join Date
    Jan 2001
    Posts
    13
    you could use the getTimer() function

    gettimer() returns the time elpased since the animation started, in milliseconds.


    Like this :

    if (gettimer()/3000)
    == math.round(gettimer()/3000) {

    on(press){
    capture.n = 1;
    }
    To
    on(press){
    capture.n = 8;
    }



    }




    Explainations : here you retrieve the number of ticks grouped by 3000 ms (so 3 seconds), and check if they are equal to an integer. That's it, it checks if timer is on 1,3,6,9,12,... seconds , and then launch your code


    Hope this works

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    419
    I don't suggest your use the get timer method, it's slow and sloppy. try this it's alot easier!

    _root.foo = function(status){
    trace(status);
    }
    setInterval(_root, "foo", 3000, "ok");

    3000 miliseconds = 3 seconds

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