Announcement

Collapse
No announcement yet.

How to force buttons click works only when mouse button released and not pressed?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to force buttons click works only when mouse button released and not pressed?

    How to force buttons click works only when mouse button released and not pressed?

    i have next problem:
    when i click on button, button code executed immediately when mouse button pressed, but i want code be executed only when mouse button released above clicked UI button.

    how to do it?

    #2
    Sorry English-speaking readers - I find it easier to explain in my language.
    С кнопкой связно масса событий. Ты используешь on(press), а нужно использовать on(release). Например:
    Code:
    on(release){
      gotoAndPlay(5);
    }
    Можно использовать такую запись:
    Code:
    myButton.onRelease = function() {
      gotoAndPlay(5);
    }
    myButton - имя кнопки. Чем лучше? Во первых можно такое привязать к кнопке, которую создал динамически, во вторых эту функцию можно менять от кадра к кадру - изменяя реакцию кнопки.

    With button connected mass events. Do you use on (press), and you want to use on (release). For example:
    Code:
    on (release) {
       gotoAndPlay (5);
    }
    You can use the following entry:
    Code:
    myButton.onRelease = function () {
       gotoAndPlay (5);
    }
    myButton - name of the button. What this version is better? Firstly this can be tied to a button, which was created dynamically, and secondly this function can change from frame to frame - changing the reaction button.

    Comment


      #3
      seamanmur tnx

      Comment


        #4
        i am using:
        Code:
        myButton.onRelease = function () {
           gotoAndPlay (5);
        }
        when i press on this button - my functions is not executed.. i need to do something else? maybe add some event listener (if yes, then how?)?

        Comment


          #5
          The Standard Flash Method

          ActionScript 2.0 Only
          1. Select your button.
          2. Open the Actions Tab.
          3. Enter this code:

          Code:
          on(release) 
          {
              trace("Button released."); 
          }

          Flash Method 2

          (NOTE: This method will not work on CLIK buttons.)

          ActionScript 2.0 Only

          Enter this code on the timeline where the button lives (not inside the button). Be sure to replace 'myButton' with the instance name of your button.

          Code:
          myButton.onRelease = function() 
          {
              trace("Button released.");
          }
          The Preferred CLIK Method
          (NOTE: This method only works when using CLIK buttons.)

          In UnrealScript you would use:

          Code:
          myButton.AddEventListener('CLIK_click', handleButtonRelease);
          
          function handleButtonRelease(GFxClikWidget.EventData ev)
          {
              `log("Button released.");
          }
          In ActionScript you would use:

          Code:
          myButton.addEventListener("click", this, "handleButtonRelease");
          
          function handleButtonRelease() 
          {
               trace("Button released.");
          }
          FYI: The press event (CLIK_press in UnrealScript) is for when the mouse button is depressed (held down but not released yet), and click (CLIK_click in UnrealScript) is for when the mouse button is released.

          Comment


            #6
            Matt Doyle
            tnx

            i have now problems with click, i exactly need to onRelease event of button.
            "click" is executed when i press button, but i need my function to be executed when i release button.

            Code:
            on(release) {
                 _root.gotoAndPlay(5); // or whatever you want to happen.
            }
            that works fine

            but next code doest work:
            Code:
            myButton.onRelease = function() {
              trace("Button released");
            }
            so i need some like this:
            In ActionScript you would use:

            Code:
            MyButton.addEventListener("click", this, "handleButtonRelease");
            but what to write instead "click"??
            words: "release" and "Release" and "onRelease" are not working

            Comment


              #7
              "click" IS on release. I can test it in Flash and see it working as expected. Be sure to put the event listener code on the timeline where your button lives, and not inside the button.

              And DO NOT USE this code for CLIK buttons. This code below will only work on non-CLIK buttons:

              Code:
              myButton.onRelease = function() {
                trace("Button released");
              }
              The code you want to use for CLIK buttons is:

              Code:
              myButton.addEventListener("click", this, "handleButtonRelease"); 
              
              function handleButtonRelease() {
                   trace("Button released");
              }
              If you aren't using a CLIK button, then the event listener code won't work.

              Comment


                #8
                Matt Doyle thanx.. really click != press
                i was mistaken.. i was sure i tried "click" instead "press"

                now all is fine and working as i need

                Comment

                Working...
                X