views:

13

answers:

1

I have a class which extends a SWC , in the swc i have two boxes, front and back and an animation on the same timeline. The animation works fine without swapping when I swap them the animation stops working. Anyway I can make it work?

I have the following code :

var frontTemp:DisplayObject = this.animationInstance.getChildByName("front");
var backTemp:DisplayObject  = this.animationInstance.getChildByName("back");
this.animationInstance.swapChildren(frontTemp,backTemp);    
this.animationInstance.gotoAndPlay("animation");
+2  A: 

The short answer is, you should avoid using both frame animations and scripts on the same objects. Basically, frame animations and scripts are two different ways to control the properties of clips (position, size, stacking order, etc). And if you use them both, Flash has no unambiguous way to know which set of instructions should take precedence. The way Flash deals with this problem is, once you use scripts to update something, it is no longer affected by frame animations from then on (unless it gets removed from the stage and re-added).

I posted a couple of general ways to fix this kind of issue in answer to this question - please have a look.

fenomas
Thank you so much for the detailed answer. My issue is I have complex animations of a character which I cannot achieve with script. The issue come here. When the arm of the character is in front of the chest. Now when the character turns the arm needs to be behind the chest. Any solutions besides script?
Fahim Akhter
The simplest way is to make two layers for arms, one above the chest and one below, and move the arm back and forth between them. Would this work?
fenomas
This would work I suppose :D I was looking for a efficient solution to it :P Thanks :D
Fahim Akhter