7 Replies Latest reply on Sep 14, 2007 4:49 PM by Ashpotter

    Target help

    Ashpotter Level 1
      I have a function that is activated by the pressing of a button. i have "on (release) {...}"
      how do i state which button to push?
        • 1. Re: Target help
          SymTsb Level 2
          is your "button" a button instance or a movie clip instance?
          • 2. Re: Target help
            Ashpotter Level 1
            it's a button instance. When i clicked on convert to symbol, i selected button if that's what you mean. (p.s if this is needed, i have flash 8)
            • 3. Re: Target help
              fanglinyong Level 1
              your code is too old ,in as2, you should rewrite your code like this:
              first :you should give your button instance a instance name ,p.s yourbutton
              sceond:
              your code should like this(the code write in the frame, not on the button instace)
              yourbutton.onRelease = function() {
              //add your code here;
              };
              if u don't konw this code ,please see the help,it can help u!!
              good luck
              • 4. Re: Target help
                Ashpotter Level 1
                thanks. i did put it in he frame that is used only for action script. Don't you need parenthesis on the Release part? In your code are you definning the function within the on.Relase or outside?
                • 5. Re: Target help
                  Ashpotter Level 1
                  i still don't get it. Heres one of my functions
                  function reset(){
                  a=0
                  b=0
                  }
                  i want to use the a button who's instance is resetbtn
                  • 6. Re: Target help
                    clbeech Level 3
                    to answer your earlier question, no you do not need the parenthesis when calling an on handler from the timeline. You can place a call to the reset function as you have defined or change the variables within the on handler, as in:

                    resetbtn.onRelease = function() {
                    a=0;
                    b=0;
                    }

                    OR, leaving the named 'reset' function in the code

                    resetbtn.onRelease = function() {
                    reset();
                    }

                    OR you can also assign the named 'reset' function to the handler, as in:

                    resetbtn.onRelease = reset;

                    you CAN call to a function from code attached to the button instance, however this is not as efficient as placing all code on the main timeline, however, with the function 'reset' on the main timeline, and attaching this to the btn instance:

                    on(release) {
                    _parent.reset();
                    }

                    there you go :)
                    • 7. Re: Target help
                      Ashpotter Level 1
                      Thanks a lot. My plan was to create a calculator with my newly acuired knowledge of variables. I got all the codes done but just couldn't get the buttons to work them. Again, thanks!