Skip to main content
markerline
Inspiring
November 11, 2010
Answered

AS3.0: Can't add child and access subchildren timelines?

  • November 11, 2010
  • 1 reply
  • 1694 views

I have the following code:

var myParent:Parent = new Parent();

var mySymbol_01:Symbol01 = new Symbol01();

var mySymbol_02:Symbol02 = new Symbol02();

myParent.x=100;

myParent.y=100;

addChild(myParent);

myParent.gotoAndStop(1);

button.addEventListener(MouseEvent.CLICK, buttonPressed);

function buttonPressed(e:Event):void{

removeChild(myParent);

playCopy();

}

function playCopy():void{

addChild(myParent);

myParent.gotoAndPlay(2);

myParent.x=100;

myParent.y=100;

//myParent.rects.width=200;

//myParent.circ.width=300;

}

If I take

//myParent.rects.width=200;

//myParent.circ.width=300;

and remove the comments, the file breaks and no Movie Clips appear on the stage.  Does this have to do with casting the Children as Movie Clips, which I may not have done here?

This topic has been closed for replies.
Correct answer Ned Murphy

No error codes Ned, it just adds the Child at the last frame in the timeline which happens to be frame 60 (I have a

n animation in the y direction just for kicks to see if I can get the animation to play and have the object move down

ward vertically but it just "pops" into place without any animation.

And no, it's not a sound animation.


I can't follow any of what you might be trying to do animation-wise, but if it is a timeline animation, it sounds like something is not being managed properly. Your describing it as just popping into place is indicative of a broken tween.

If you are doing something to whatever symbol involves the tweening, like if those lines where you change widths involves objects related to the tween, then that is likely your problem.  You cannot change the characteristics of an object that is tied into a timeline tween.  The tween is set up for specific conditions, and changing something like the width of a tweened object will break it.

1 reply

markerline
Inspiring
November 11, 2010

UPDATE:

After changing some y values I found that the children were being added to the stage.  However, the animation that happens within their timeline does not happen on the stage with comments removed as described above.  I can't figure out if this is a bug or if I'm writing the code improperly.

Ned Murphy
Legend
November 11, 2010

When the file breaks, are you getting error messages?  I don't readily see anything errant with the code, but any bug is more likely to be a result of something amiss in your design and not something of the software, assuming you have a sound installation.

markerline
Inspiring
November 11, 2010

No error codes Ned, it just adds the Child at the last frame in the timeline which happens to be frame 60 (I have a

n animation in the y direction just for kicks to see if I can get the animation to play and have the object move down

ward vertically but it just "pops" into place without any animation.

And no, it's not a sound animation.