A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: simple timer

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    26

    Unhappy simple timer

    Hey, im making a timer attached to a button
    i have tried a couple of differend types but it does not fill my needs
    i also need it to be simple as im not very experienced yet

    on(press)
    {
    timer1 = function()
    {
    something++;
    }
    timer1Interval = setInterval(timer1,1000)
    }

    "something" will now add up every second

    now i want to make a max, like 10

    if(something > 10)
    {
    something = 10
    }

    dont know for sure if the above works in this case, but something like it worked for me when i:
    pasted it on the frame itself (as soon i entered the frame it resets to 10
    pasted it on a button (as soon i clicked the button it resets to 10

    but what ever way or place i try it will not happen
    without any kind of event

    is there any simple timer that can do this without any event,
    or is there a simple function to make it check the timer
    every milisecond for updates like:
    updater = function blabla,
    if(something > 10) blabla
    setinterval(repeat,1) anything like that?

    thx in advance

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Why not just check in the function itself, and then remove the interval?

    Actionscript Code:
    on(press)
    {
        timer1 = function()
        {
            if(something < 10){
                something++;
            } else {
                clearInterval(timer1Interval);
            }
        }
        timer1Interval = setInterval(timer1,1000)
    }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    May 2010
    Posts
    26

    solved

    thx for the reply i was very close to that il gues
    but it would never work anyway if i didnt knew i needed
    clearInterval(timer1Interval) instead of clearInterval(timer1)

Tags for this Thread

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