Skip to main content
BioME
Known Participant
January 25, 2023
Answered

Buttons Stuck on Over frame

  • January 25, 2023
  • 3 replies
  • 1055 views

This is a follow up to a post I submitted last November, labeled "Wonky Buttons with Canvas."  kglad responded, but didn't followup to my last response which I imagine means he couldn't answer the question, no problem.  However, this is important to my project so I want to be sure that no one has any suggestions.

 

What's happening is if I click a button it gets stuck on the over frame.  When I move the cursor off the button after I've clicked it doesn't go back to the Up frame. Instead, it goes to the Over frame.   

 

Does anyone have any suggestions, or is this just a bug with Canvas that we have to live with?

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

     

    You shouldn't need code to only change a button to the Over and Up frames. If you use the default Button symbol, Animate will handle this interactivity automatically for you.

     

    Also, by only calling stopPropagation will cause a runtime error. If you really need to use it, you must call it on the event object. Like this:

    this.yourButton.on("click", function(e){ e.stopPropagation(); });

     

    And for other users, I would like to emphasize that buttons never go to the Hit frame. The instances placed in there will only be used as region/area for mouse interactions.

     

    Regards,

    JC

    3 replies

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    January 30, 2023

    Hi.

     

    You shouldn't need code to only change a button to the Over and Up frames. If you use the default Button symbol, Animate will handle this interactivity automatically for you.

     

    Also, by only calling stopPropagation will cause a runtime error. If you really need to use it, you must call it on the event object. Like this:

    this.yourButton.on("click", function(e){ e.stopPropagation(); });

     

    And for other users, I would like to emphasize that buttons never go to the Hit frame. The instances placed in there will only be used as region/area for mouse interactions.

     

    Regards,

    JC

    BioME
    BioMEAuthor
    Known Participant
    January 30, 2023

    Thanks for the advise JoãoCésar, very helpful.  You are correct that I don't need code for my buttons to change between the up and over frames, but I do need it to program the buttons so they will do what I need them to do.  Kglad has already advised that I should remove the stopPropagation command, and I'm anxious to try it.  Unfortunately, my laptop is in repairs right now; I'm using a loaner for communications.  I will experiment with you code for incorporating a stopPropagation command when needed.  I'm forgeting why I put it in the first place so I may need it, although I bet I don't. Thanks again, BioME

    BioME
    BioMEAuthor
    Known Participant
    January 31, 2023

    Just letting folks know the bug is fixed.  Turns out I did need the stopPropagation command, but adding the event parameter as JoãoCésar suggested solved the problem.  Without the stopProgation command, what was happening when I clicked a back button is that it would go back to the designated keyframe in my timeline, but then it would just play back to the current keyframe, even though I used a gotoAndStop command.  Thanks kglad and JoãoCésar for helping work this out, BioME

    Community Expert
    January 25, 2023

    Kglad will help you figure it out. Even if he doesn't know it, he will figure it out. Just get him the file or your code. 

     

    kglad
    Community Expert
    Community Expert
    January 25, 2023

    don't remember that, but upload your fla to a file server and post a link here.

    BioME
    BioMEAuthor
    Known Participant
    January 26, 2023

    Thanks so much kglad.  Don't worry about not remembering.  You're so supportive to so many that I for one would never fault you if an inquiry falling through the cracks.  I will post a fla on a server as you ask, but right now my laptop is in my IT department for repairs so it may take a few days.  I'll let you know when it's ready.  In the meantime, if you want to review the previous inquiry then you could look up the Wonky Buttons with Canvas conversation we had last

    fall.  If you don't have time don't worry about it, you can just look at the fla when I get it up.

    kglad
    Community Expert
    Community Expert
    January 26, 2023

    oh, no need to upload your fla. i see the problem from your other thread.

     

    when you use:

     

    var _this = this;

    _this.BTN_Name.on('click', function(){

    _this.gotoAndStop("previousFreezeFrame");

    stopPropagation();

    });

     

    stopPropagation() is going to prevent any response to the click event after that code excutes, including the button responding after it goes to the down frame.  ie, remove that stopPropagation() and your button will behave as you expect.

     

    if you need stopPropagation() for something else, see if you can use a "pressup" event instead of "click". the pressup even won't interfere with the button changes you expect.