Skip to main content
mordaga2015
Participant
May 3, 2024
Question

How do I target an "unnamed" child movieclip inside a "named" parent movieclip?

  • May 3, 2024
  • 1 reply
  • 252 views

I'm starting a new post about this to minimize hijacking the original post where I posed the subject question. (https://community.adobe.com/t5/animate-discussions/identify-an-instance-by-the-name/m-p/9319295)

 

My question/problem:

I have a series of "named" movieclips that each contain the same "unnamed" movieclip (on the second frame of the parent MC). I want to play the inner movieclip when a button (targeting the parent MC) is clicked.

 

@JoãoCésar17023019  posted this reply:

You could do something like this:

 

function playInnerMC(e)
{
	e.currentTarget.gotoAndStop(1);
	e.currentTarget.children[0].gotoAndPlay(1);
}

this.parentMC.on("click", playInnerMC);

 

 

I think this is pointing me in the right direction, however I am getting an error in the console...

 

Uncaught TypeError: root[root.pageInstance][root.narrationMovieInstance].children[0].gotoAndPlay is not a function

 

root is a reference to "this" on my main timeline (var root = this;)

 

Could the error be occuring because the parent MC (narrationMovieIntance) contains a text layer "above" the movieclip I want to play?

Since the text is not a movieclip is this causing the "gotoAndPlay" error?

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    May 3, 2024

    my answer to your previous post is the same. you need more info about those movieclips, though we know more now (as3) than before.

    mordaga2015
    Participant
    May 4, 2024

    My current workaround is to give all the child movieclips the same instance name.
    Not as nice as I would like but it functions:

    root[root.pageInstance][root.narrationMovieInstance].i_text_highlight.gotoAndPlay(1);

     

    kglad
    Community Expert
    Community Expert
    May 4, 2024

    glad you have it resolved.