Skip to main content
Participant
June 2, 2014
Question

Referencing a "Nested" MovieClip or "childMovieClip"

  • June 2, 2014
  • 1 reply
  • 314 views

Hello all.

I am fairly new to Flash and AS3 so bare with me. I am designing a simple interactive animation. In this interactive file, I have a tree branch. I have a button (leaves_btn) near the branch that once clicked, about 8 leaves will bloom from the tree. I have all of the leaves compressed into a childMovieClip labeled as "leaves8". I am having trouble getting the button on the main timeline to play my "leaves8" movieclip that is nested.

Any help would be greatly appreciated.

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
June 2, 2014

What is the code you are using that you are having trouble with?  Do you get any error messages?

Participant
June 2, 2014

theleafbtn.addEventListener(MouseEvent.CLICK, thefunction);

function thefunction(event:MouseEvent):void {

    leaves8.gotoAndPlay(1);

}

ERROR:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

  at Untitled_1_fla::MainTimeline/thefunction()

Participant
June 2, 2014

You said the leaves8 object is nested, but did niot indicate in what object it is nested.  If that code is on the main timeline, then you need to target the leaves8 thru the object it is in.  If it happens to be in the branch object and that is the name you gave it then you would use...

theleafbtn.addEventListener(MouseEvent.CLICK, thefunction);

function thefunction(event:MouseEvent):void {
    branch.leaves8.gotoAndPlay(1);
}


Forgive my ignorance.

I was probably not clear in my initial question.

I have 8 leaves that have been converted to symbols which are all individually animated. I selected all of the leaves and converted the group into a single movieclip that is labeled "leaves8".

On the main timeline it is a single frame. I am wanting to link to that single movieclip (leaves8) to play it.

I hope this makes sense.