1 Reply Latest reply: Aug 5, 2012 10:23 AM by Production Monkey RSS

    Timer countdown problem

    anjemalo Community Member

      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

        • 1. Re: Timer countdown problem
          Production Monkey Community Member

          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