Skip to main content
Participating Frequently
July 16, 2019
Answered

Accessing nested movie clips with ActionScript 3.0

  • July 16, 2019
  • 2 replies
  • 1796 views

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.

This topic has been closed for replies.
Correct answer Joseph Labrecque

Check your Document Settings and be sure "Advanced Layers" is toggled off. With it on, it creates an additional symbol based on the entire layer name. Alternatively, you can try something like:  square1.LAYER_NAME.circle1 or whatnot.

2 replies

Joseph Labrecque
Community Expert
Joseph LabrecqueCommunity ExpertCorrect answer
Community Expert
July 17, 2019

Check your Document Settings and be sure "Advanced Layers" is toggled off. With it on, it creates an additional symbol based on the entire layer name. Alternatively, you can try something like:  square1.LAYER_NAME.circle1 or whatnot.

LuisEAuthor
Participating Frequently
July 17, 2019

Thanks a lot, Joseph!

That was it!

kglad
Community Expert
Community Expert
July 16, 2019

is circle in frame 1 of square?

LuisEAuthor
Participating Frequently
July 16, 2019

It is on the first frame of the "square" movie clip, but on a second layer.

However, that doesn't seem to be a problem with the first function.

kglad
Community Expert
Community Expert
July 16, 2019

click file>publish settings and tick 'permit debugging'.  retest.

the problematic line of code will be in the error message.  if that line of code is:

square.circle.addEventListener(MouseEvent.MOUSE_OVER, overCircle);

either there is no square instance in the frame that contains the above code or there's no circle instance in frame 1 of square.