4 Replies Latest reply on Dec 12, 2006 1:46 AM by duckets

    Making a delay on button action

    JustJc51
      I have made a little experiment, navigating using the mouseEnter command, but have found that this makes the navigation a bit to fast and easy to make mistakes in. So I was wondering if someone could help me with a script that requiers the user to stay on the button for a ½ second before it reacts.

      Current Lingo is the simple
      on mouseEnter
      go to frame 3
      end

      Thanks in advance!
        • 1. Re: Making a delay on button action
          Level 7
          The normal user interaction method for selecting something is to use a
          mouse click event. Mouse enter is used to show the user that something
          is selectable. Mouse down is used to show that the rolled over item is
          active, and mouse up is used to register that selection. Using mouse up
          allows the user to drag off the item and de-select it.

          Are you working on a game where you want to add an element of surprise?

          --
          Rob
          _______
          Rob Dillon
          Adobe Community Expert
          http://www.ddg-designs.com
          412-243-9119

          http://www.macromedia.com/software/trial/
          • 2. Re: Making a delay on button action
            Level 7
            The ugly way is to do the following

            on MouseEnter me
            targetMS = the milliseconds + 500 -- delay of 1/2 second
            repeat while the milliseconds < targetMS
            nothing
            end repeat
            go to frame 3
            end

            This would probably be ok but in general I avoid this because it ties up the
            processor and will halt video or other actions in your project.

            A better way is...

            property pTargetMS

            on beginSprite me
            pTargetMS = 0
            end

            on mouseEnter me
            pTargetMS = the milliseconds + 500 -- again, 1/2 second delay
            end

            on exitFrame me
            if pTargetMS <> 0 then
            if the milliseconds > pTargetMS then
            go to frame 3
            end if
            end if
            end

            But one doesn't typically see navigation code in a mouseEnter handler but
            that's a choice.

            Craig


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

            www.wordofmouthpros.com
            "JustJc51" <webforumsuser@macromedia.com> wrote in message
            news:eljbds$puu$1@forums.macromedia.com...
            >I have made a little experiment, navigating using the mouseEnter command,
            >but
            > have found that this makes the navigation a bit to fast and easy to make
            > mistakes in. So I was wondering if someone could help me with a script
            > that
            > requiers the user to stay on the button for a ½ second before it reacts.
            >
            > Current Lingo is the simple
            > on mouseEnter
            > go to frame 3
            > end
            >
            > Thanks in advance!
            >


            • 3. Making a delay on button action
              JustJc51 Level 1
              Thank you for the good and quick answers!

              The use is that I am writing a project, on the subject of interface design, asking if the usual click method allways is the best way or just the usual way. The reason for the request of a delay was that I found it impossible to avoid activating the buttons I hit by mistake. The ½ second comes from the popular belief that that is the reactiontime of an averange human, and that I figured that it would be easy to change, to a larger amount of time, if I found I needed more time. If I have to dismiss a point to activate interface I at least have to give it a fair chance.

              Once again thank for the help!

              Upon trying out the scripts, in one of my interfaces, I found that the solution offered just delays the time from the button has been touched till action is taken.

              What I need is a script that says, if mouse enters for more than 500ms then start action. Anyone who can help me with that one?
              • 4. Re: Making a delay on button action
                duckets Level 1
                How about something like this. It's very similar to Craig's code, but I think his slightly missed one point - which was that if the user moves the mouse back out of the sprite within 500ms, the action should not be performed.

                The 'doneAction' variable is used to make sure the action is only performed once.

                This is a behaviour script, so to use it you need to create a new behaviour, paste in the code, then place that behaviour onto a sprite. (note, this is not the same as putting code onto a cast member in the cast!).

                hope this helps!

                - Ben