Skip navigation
Currently Being Moderated

Timer countdown problem

Aug 5, 2012 1:35 AM

Hello:

I have made a behavior with a countdown timer. It works. But the problem is when I use it with two or more textbox the counter don't stop and begin to count at the same time. I need to stop the previous timer when you click over another timer (textbox). This is my code. Thank you very much:

 

property Waiting

property Working

property pNombre

global Seg

 

on getPropertyDescriptionList

  -- create an empty property list called pList

  set pList = [:]

  addProp pList, #Waiting, [#comment : "How much wait", #format :#integer,default:0]

  addProp pList, #pNombre, [#comment : "Member", #format :#string ,default:""]

  return pList

end

 

on BeginSprite me

   Working = False

  pNombre=sprite(me.SpriteNum).member.name

  member(pNombre).text="" & Waiting

 

end

 

on exitFrame me

  If Working then

    if Waiting-Seg <=0 then

      Working=false

      Seg=0

     -- put "the End" && Waiting+Seg

    else

      --Counting waiting

      Seg=the timer/60

      member(pNombre).text=""& Waiting-Seg

    end if

   

  end if

 

  go to the frame

end

On MouseDown me

    starttimer

  member(pNombre).text="" & Waiting

  Seg=(the timer/60)--  Waiting

  Working=True

end

 
Replies
  • Currently Being Moderated
    Aug 5, 2012 10:23 AM   in reply to anjemalo

    All you need to do is send a message to the other sprites to stop counting using "sendAllSprites()".

     

    On MouseDown me

      sendAllSprites(#stop)  -- ******   Add this line to your handler. ******

      starttimer

      member(pNombre).text="" & Waiting

      Seg=(the timer/60)--  Waiting

      Working=True

    end

     

     

    on stop me    -- **** Add this handler  *****

      Working = false

    end stop

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points