3 Replies Latest reply on May 1, 2007 11:49 AM by jclegs

    getting the movie to delay executing code after a sprite is clicked

    jclegs
      Hi
      I'm looking to know how I could get director to delay executing code after a sprite is clicked. When I click the sprite it changes its member and plays a sound but after a few seconds I would like it to reset and have so far written a couple of custom handlers to do this but would like director to pause executing this code for a few seconds and still play the movie. Is there anyway to do this?

      Thanks
        • 1. Re: getting the movie to delay executing code after it is clicked
          Level 7
          property pPause

          on beginSprite me
          pPause = #off
          end

          on mouseUp me
          pPause = the milliseconds
          -- include your code here that you've already written
          -- that will execute immediately
          end

          on exitFrame me
          if pPause <> #off then
          if the milliseconds > pPause + 1000* 5 then
          -- I've used 5 seconds. Change the 5 to whatever
          -- number of seconds you need.
          ---execute the code or handler that was to be delayed
          pPause = #off
          end if
          end if
          end

          --
          Craig Wollman
          Lingo Specialist
          Word of Mouth Productions
          212-928-9581

          www.wordofmouthpros.com
          "jclegs" <webforumsuser@macromedia.com> wrote in message
          news:f17dd1$rkt$1@forums.macromedia.com...
          > Hi
          > I'm looking to know how I could get director to delay executing code after
          > a
          > sprite is clicked. When I click the sprite it changes its member and plays
          > a
          > sound but after a few seconds I would like it to reset and have so far
          > written
          > a couple of custom handlers to do this but would like director to pause
          > executing this code for a few seconds and still play the movie. Is there
          > anyway
          > to do this?
          >
          > Thanks
          >


          • 2. Re: getting the movie to delay executing code after a sprite is clicked
            James Newton, ACP Level 3
            You could use a timeOut object.

            on mouseUp(me)
            vTimeOut = timeOut().new("Reset", 5000, #Reset, me)
            -- vTimeOut = timeOut("Reset").new(5000, #Reset, me) -- for D9 and earlier
            end

            on Reset(me, aTimeOut)
            aTimeOut.target = VOID
            aTimeOut.forget()

            -- Put your reset code here
            end
            • 3. Re: getting the movie to delay executing code after a sprite is clicked
              jclegs Level 1
              Thanks very much for the replies. Works prefectly thanks for taking the time to help.