Skip to main content
TheOriginalGC
Community Expert
Community Expert
Jul 18, 2022 1:53 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
    JoãoCésar17023019
    JoãoCésar17023019Correct answer
    Community Expert
    Jul 18, 2022 2:07 PM UTC

    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

    3 replies

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    Jul 18, 2022 2:07 PM UTC

    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

    Translate
    TheOriginalGC
    Community Expert
    Community Expert
    Jul 18, 2022 2:13 PM UTC

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

    Translate
    JoãoCésar17023019
    Community Expert
    Community Expert
    Jul 18, 2022 2:18 PM UTC

    You're welcome!

     

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

     

    JC

    Translate