ActionScript & Flash
Control an embedded SWF timeline
An embedded SWF can provide a MovieClip animation inside a larger game. Cast the instantiated asset to MovieClip before using timeline methods, and check that it actually exposes the frames or labels your code expects.
Use frame labels such as idle, run and hit rather than scattering numerical frame positions throughout the game. The labels form a small contract between animation and gameplay, letting artwork change without forcing every caller to know a new frame number.
Stop the clip when the surrounding game pauses. Timeline animation and simulation timers can otherwise drift apart, leaving collision state on one frame while the visible character continues moving.
Try the idea
var actor:MovieClip = new EmbeddedActor() as MovieClip;
if (actor) {
addChild(actor);
actor.gotoAndStop("idle");
}