[as3] How to replace a character movie clip with another one?
The idea for my game is this: the main character runs around the screen and there's other AI characters walking around. He walks up to one and presses "enter" and then an animation of him strangling that AI character begins.
Since the AI characters are going to look different from each other (e.g. male female, different hair color, etc.), does this mean you have to make a new strangling animation for EACH AI character, or can you create ONE strangling animation with a generic, blank character movieclip, and (then using code) replace that movieclip with the proper AI movieclip?
When you know are.
The description makes me laugh, haha!
You could do it both ways. It's probably easier to do it as separate movieclips for each character, but more tedious work. It's probably more reasonable to do one animation, and switch the art within each of the body parts.
So for instance a walk animation timeline would have 2 arms, a head, a body, 2 legs, etc. You can animate along that timeline. The first frame of the animation, or the code telling the animation to play, would tell each body part to gotoAndStop() at a different frame.
Each one of those body parts would stop on the first frame, but have several frames with different art. So the head would have 5 frames, with 5 different heads. By giving each movieclip an instance name, you can target that movieclip and tell it which frame to go to.
Then the code would be something like this for enemy #3.
The movieclip should stay the same as it moves along the timeline and through keyframes, but it will revert back to the first frame if you switch movieclips (like if you have 2 hands, one closed and one open). You'll have to call that code each time the movieclip changes.
In that case, it's probably better for the movieclip itself to check on the first frame. It could check to see which enemy it is from its parent, and switch to the correct frame.
Something like that. Both of these solutions seem kinda hacky to me, but if you fiddle with them you'll eventually get it to work. That's what Flash is all about! haha
// inside of the arm movieclip with 5 frames
int myNum = MovieClip(parent).enemyNum;
I'll try that out, thanks!
Click Here to Expand Forum to Full Width
Poll by Flashkit.com