Search code examples
actionscript-3tween

AS3 Tween dynamically created object along with other object


I'm trying to dynamically addChild a Sprite to an already tweened MovieClip (tweened on the Flash timeline). Let's say ObjectA is the tweened object, I published it in my swc and linked it to my Actionscript project in Flash Builder. I make an instance of ObjectA in my class, and then try to do the following:

var objectA:ObjectA = new ObjectA(); var objectB:ObjectB = new ObjectB();

objectA.addChild(objectB); addChild(objectA);

Now, the problem is, objectB doesn't tween along with objectA. Is there any logical solution to this?

Thanks in advance, Jennifer


Solution

  • The example looks ok... now, are you actually tweening objectA and not a container or shape inside of objectA ? If this is the case, make the object inside a container and add objectB to it : objectA.tweenedObject.addChild(objectB).