View Full Version : [AS3] How to replace(swap) movieclips?

11-09-2010, 12:39 PM
Hi, I'm trying to learn a bit more about game making and I am making a simple survival type side scrolling shooting game.

What I have done is character movement, playing the animation of him walking when you press the side arrows, and making him flip the other way when you press the opposite direction your going....

What I would like to know is how to swap the original movie clip of him, with a movie clip of him ducking when you press down, and if you hold down and direction keys(left and right), then it plays the movie clip of him walking in the crouched position...

So basically i would like to replace the movie clip with another movie clip from the LIBRARY(I know how to export on to the stage from library) into the position where the previous movie clip was, and the old movie clip of him standing goes away, when you let go of down, he stands back up.

Code and explantion please, thank you.:confused:

11-09-2010, 01:16 PM
Did you try removeChild for the walking mc and addChild for the crouched?

11-09-2010, 04:11 PM
I have tried addChild, but I want it to be positioned where the standing movie clip was, just so you know,

The running movie clip is called player_mc, which consists of movie clips of his legs running(his legs are a movie clip), arms that give the running effect and the head for breathing, this player_mc movie clip is on the stage,

Q1.Should I export player_mc from the library too?

Q2.I want the crouching movie clip to be in the exact position of the player_mc, how?

Q3.Do I have to addChild to the stage or movie clip?

thx, hoping for a reply soon :)-