Skip to main content
markerline
Inspiring
September 24, 2013
Answered

how to use one button to drive another button click

  • September 24, 2013
  • 1 reply
  • 1008 views

I'm trying to figure out a way to fix a bug in my application.  The simple fix would be to have a single button that drives a MouseCLICK event on another button everytime the PlayBar in my application reaches the end of the screen and returns to its origin.

How would I achieve this?  I have made a lot of headway since I last posted a question in the ActionScript 3 forum, which was only yesterday evening.

Thanks in advance,

markerline

This topic has been closed for replies.
Correct answer Ned Murphy

If you simply need to execute the function that one of the buttons would otherwise execute when clicked, then just call that function when you need to.  If you set the event argument to null in the function you can call it without havoing to have clicked anything...

function whateverBtnClicked(evt:MouseEvent=null):void {

     etc...

So if you need to execute that function without having clicked the buttion you can just use...

whateverBtnClicked();

1 reply

Ned Murphy
Legend
September 24, 2013

What do you mean by "drives a MouseCLICK event on another button"  and what is that supposed to do that reconciles whatever bug you have?

markerline
Inspiring
September 24, 2013

The application is an audio application.  It is like a drum machine sort of.

Currently there is a grid and whenever active cells get hitTest'ed by the PlayBar they become deactivated, the PlayBar returns to the origin, and when you relaunch the Play functionality the deactivated cells no longer play a sound.

I have a button which reactivates the sounds.

I also have a button which has a bug in it that loops the sounds. 

To go around the looper button that has a bug in it I would like to use a Button "Z" which automatically clicks the "reactivate the sounds" button every time the PlayBar returns to the origin and the PlayBar will then continue to play and return to the origin in a looping fashion.  If the Button Z is in an active state this looping will continue.  To stop looping, click the Button Z until it is no longer in an active state and the PlayBar will then remain at the origin.

Ned Murphy
Ned MurphyCorrect answer
Legend
September 24, 2013

If you simply need to execute the function that one of the buttons would otherwise execute when clicked, then just call that function when you need to.  If you set the event argument to null in the function you can call it without havoing to have clicked anything...

function whateverBtnClicked(evt:MouseEvent=null):void {

     etc...

So if you need to execute that function without having clicked the buttion you can just use...

whateverBtnClicked();