Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to use one button to drive another button click

Mentor ,
Sep 24, 2013 Sep 24, 2013

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

TOPICS
ActionScript
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 24, 2013 Sep 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();

Translate
LEGEND ,
Sep 24, 2013 Sep 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Sep 24, 2013 Sep 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 24, 2013 Sep 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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Sep 24, 2013 Sep 24, 2013
LATEST

Ned, I think that is the answer I was looking for.  Because what was getting in the way was the MouseEvent that had to be passed into the function.  Setting it to null may do the trick.  If I set it to null though, will the original button still work with the MouseEvent handler passed in?  Not sure if that's a valid question but I will try to execute this now and get back to you with results.

Thanks for your response.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Sep 24, 2013 Sep 24, 2013

The bug with the looper button is that activated sounds play redundantly on each hitTest using hitTestObject as the method.  That is to say that sounds from a given cell are repeated at a rapid speed, giving the impression that there is an echo, which is not a desired effect that I am trying to achieve.  I need clean breaks of sounds.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines