Accessing nested movie clips with ActionScript 3.0
Hi!
I'm starting to learn AS3.0 with a book from 2011 and most things seem to function the same.
However, I'm having trouble accessing nested movie clips inside other movie clips.
I created a new simple document just to try this:
I made a movie clip called "square", and inside it I made another movie cilp called "circle".
Then, back on the main stage I created a "button" movie clip to manipulate the "circle" movie clip (which worked just fine).
However, when I tried to make a simple trace statement with a Mouse Over function on to the "circle" movie clip, it doesn't work:
| Code |
|---|
import flash.events.MouseEvent; //Here, the function accesses the "circle" movieclip buttonCircle.addEventListener(MouseEvent.CLICK, changeCircle); function changeCircle(e:MouseEvent):void { square.circle.gotoAndStop("yellow"); } //Here, I can't access the circle movieclip square.circle.addEventListener(MouseEvent.MOUSE_OVER, overCircle); function overCircle(e:MouseEvent):void { trace("Circle"); } |
I get the following message on the Output:
| Output |
|---|
TypeError: Error #1010: A term is undefined and has no properties. at Untitled_1_fla::MainTimeline/frame1() |
Does anyone know why this happens?
Thanks a lot in advanced.
