Skip to main content
TheOriginalGC
Community Expert
Community Expert
July 18, 2022
Answered

Trying to trigger a function from the end of a MC.

  • July 18, 2022
  • 1 reply
  • 248 views

I have a movie clip plays a sound at the end of the timeline. So far, so good. I also want to trigger a function in the parent of the animation, using "this.parent.stars();" but the function isn't getting called. Clearly I am doing something wrong. What's the issue?

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

    Hi.

     

    Plase make sure that stars is a method that belongs to the parent timeline and not a function.

     

    Meaning that this...

    function stars() // wrong
    {
        console.log("not gonna be called");
    }

     

    ... is different from this:

    this.stars = function() // correct
    {
        console.log("this is gonna be called");
    };

     

    So double check if your case is similar to the second example.

     

    I hope this helps.

     

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    July 18, 2022

    Hi.

     

    Plase make sure that stars is a method that belongs to the parent timeline and not a function.

     

    Meaning that this...

    function stars() // wrong
    {
        console.log("not gonna be called");
    }

     

    ... is different from this:

    this.stars = function() // correct
    {
        console.log("this is gonna be called");
    };

     

    So double check if your case is similar to the second example.

     

    I hope this helps.

     

    Regards,

    JC

    TheOriginalGC
    Community Expert
    Community Expert
    July 18, 2022

    Wow, I never would have guessed that in a million years. Thanks for your help!

    JoãoCésar17023019
    Community Expert
    Community Expert
    July 18, 2022

    You're welcome!

     

    And don't worry because this difference is not obvious at all!

     

    JC