1 Reply Latest reply on Jul 11, 2006 2:49 AM by blemmo

    Can I fake a button was pressed?

    thy1225
      I have two buttons("b1_btn" and "b2_btn" ) and they are in different layers.
      Here's what I hope to do, when people click on "b1_btn", I hope it can act exactly the same like "b2_btn" when it was clicked.
      The actionscript in "b2_btn" is a little mess, and since two buttons are in different layers, so I hope I don't have to copy the actionscript to "b1_btn" and check every line manualy.....
      so is there any way to link two buttons together? so click on b1_btn will act like click on b2_btn.
      like the code below........is my imagination...

      b1_btn.onRelease=function(){
      b2_btn.onRelease();
      }

      hope you understand what I'm saying.....(I tried my best to explain in english)
        • 1. Re: Can I fake a button was pressed?
          blemmo
          The code you posted should do it. You can also have your button code in a named function, and assign this to the events:

          function onButtonPress(){
          // code here
          }

          b1_btn.onRelease = b2_btn.onRelease = onButtonPress;

          No brackets () in the last line, so the function won't execute.

          hth,
          blemmo