Skip to main content
Participant
June 2, 2014
質問

Referencing a "Nested" MovieClip or "childMovieClip"

  • June 2, 2014
  • 返信数 1.
  • 314 ビュー

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.

このトピックへの返信は締め切られました。

返信数 1

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?

Bettis23831作成者
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()

Ned Murphy
Legend
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);
}