last week or so i saw someone asking for frames on a sprite and "gotoAndStop".
since we all use some kind of work around i though i share mine with you.
i wrote a little extension called FrameSprite. what this class does it very simple.
this class extends the starling.display.Sprite and is able to do everything you would want to do with a normal sprite.
Difference is that with this Sprite you can add frames to your sprite and give them labels just like you would do with flash.
the example below shows you how this class works.
//texture atlas var player_jumpAtlas:TextureAtlas = new BigTextureAtlas([tex1],[xml1]); var player_walkleftAtlas:TextureAtlas = new BigTextureAtlas([tex2],[xml2]); //we create the player sprite witch is going to contain all the animations it hass. var player:FrameSprite = new FrameSprite(); //we create the player jumping movieclip. var player_jump:MovieClip = new MovieClip(player_jumpAtlas.getTextures()); //add the mc to the juggler like you would normaly do. Starling.juggler.add(player_jump); //we create the player walking to the left movieclip. var player_walkleft:MovieClip = new MovieClip(player_walkleftAtlas.getTextures()); Starling.juggler.add(player_walkleft); //we add the player sprite to the stage addChild(player); //first we must add a frame to the FrameSprite player.addFrame("playerjump"); //with the addChildToFrame function you can add a mc to a specific frame within the player sprite a frame, both frame number and framelaber work here. player.addChildToFrame(player_jump, 1); //here we do the same as shown above but we give the seccond frame a diffrent name. player.addFrame("playerwalkleft"); player.addChildToFrame(player_walkleft, 2); //with the gotoAndStop functie you can give a frame label or the frame number, both work. player.gotoAndStop(2); player.gotoAndStop("playerjump"); //this returns the frame number currently active. player.currentFrame; //this returns the frame label currently active player.currentFrameLabel; //this returns the current frame sprite holder var frame_sprite:Sprite = player.currentFrameSprite; //for example, lets give this mc a name player_jump.name = "player_jump_mc"; // with could find this specific mc now with player_jump = MovieClip(frame_sprite.getChildByName("player_jump_mc")); //removeFrame can give number or string. player.removeFrame(1); player.removeFrame("playerjump"); //isnt this obvious? player.prevFrame(); player.nextFrame();