Skip to main content
ramóngarcía
Participant
February 10, 2023
Answered

The link is not working. Animate and Canvas

  • February 10, 2023
  • 1 reply
  • 424 views

Hi

I have a movie clilp with 3 frames.

The first and the second are the choises selected.

The third one has 2 butons to select.

When I click on the mc, it goes to the third frame and display the options.

Then when I click in any option, I made changes (this works) and I want the movie click to return to the selected option, but this doesn't work

I have this code:

this.control_mc.addEventListener("click", control_1.bind(this));
function control_1() {

         this.control_mc.gotoAndStop("select"); //this is working with no problems

}

this.control_mc.manual_btn.addEventListener("click", manual_sel.bind(this));
function manual_sel() {
       this.control_mc.gotoAndStop("manual"); //Here I have few more lines that works as well, but the control_mc doesn't go to "manual"

}

 

Any idea?

Thank you

    This topic has been closed for replies.
    Correct answer ramóngarcía

    It's a parameter of the function.

     

    function manual_sel(e) // <-- the event object (in this case called e)
    {
    	e.stopPropagation();
    	this.control_mc.gotoAndStop("manual");
    }

     


    Perfect. It works.

    Thank you for your help. 

     

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    February 10, 2023

    Hi.

     

    I think it's because the listener you added to control_mc fires after the event you added to manual_btn. In this way the container will always go to the "select" label.

     

    One possible solution will be to stop event propagation in the listener will added to manual_btn so that when you click exactly on it, the parent (control_mc) won't be notified. Like this:

     

    function manual_sel(e)
    {
        e.stopPropagation();
        this.control_mc.gotoAndStop("manual");
    }

     


    I hope it helps.

     

    Regards,

    JC

    ramóngarcía
    Participant
    February 10, 2023

    Thank you for the answer

    I got "e is not deffined". I tested with "var e = event", but it doen't work either

    JoãoCésar17023019
    Community Expert
    Community Expert
    February 10, 2023

    It's a parameter of the function.

     

    function manual_sel(e) // <-- the event object (in this case called e)
    {
    	e.stopPropagation();
    	this.control_mc.gotoAndStop("manual");
    }