Accessing animation of nested symbols using AS3 in Flash CS4 - actionscript-3

It's for my college project again.
I am making a Zombie shoot-em-up game. I created a Zombi symbol with the default Zombie sprite. Inside the symbol I placed three more sprites that are ZombiAttack, ZombiIdle, and ZombiMove, in the frames 1, 15 and 20 respectively. I further converted the sprites to symbols and inside their respective symbols I placed the remaining sprites. So it's like this:
Zombi (Main Symbol):
ZombiAttack (in Frame 1):
inside this I placed the remaining Zombie Attack sprites placed at intervals of 5 frames.
ZombiIdle (in Frame 15):
inside this I placed the remaining Zombie Idle sprites placed at intervals of 5 frames.
ZombiMove (in Frame 20):
inside this I placed the remaining Zombie Move sprites placed at intervals of 5 frames.
In the Zombi Class File I used the following code in the ENTER_FRAME listener's function:
this.gotoAndPlay(20); //For the moving animation of the Zombie.
This plays a static image of the frame 20 and not what's inside it (which I want it to play).
Now, my question is how do I do that? How do I play the nested symbols animation and control it further?
I've found a few posts that address a similar problem but the solution for them isn't working for me as many posts were dated back to 2004 and 2005.
Thanks in advance! :)

Make sure all your symbols are movieclips and give them instance names in the property inspector. (For example, you can name the idle animation "idle_mc").
You could place this actionscript on frame 15:
idle_mc.play();
To make sure that idle_mc plays after the playhead jumps to frame 15. You can also put a play(); command inside the idle animation on frame 1, just to make sure it plays.

Related

Avatar Layering and Animating in Flash

So for my latest Flash project, I'm designing a game. The dimetric character can move in 8 directions. I've been given the spritesheets for the hats, hair styles, etc., that the player can wear.
The spritesheets contain the images for each direction, AND they contain four frames of animation (four per direction) for when the player is walking. This is basically the layout of the Spritesheet (and all of the files and "frames" are the same size, which makes things easier):
[IDLE] [WALKING]
[S][SE][E][N][NW][W][S1][S2][S3][S4][SE1][SE2]...
My goal is to embed all of the items in a single file other than the main one. But I need to implement walking animation.
One thought I had is to set the main SWF's framerate to 7 FPS, then use an Event.ENTER_FRAME handler to alternate between the walking ones. Programmatically animating.
Another thought is to create SWFs for each item of clothing, then use motion tweening to move the spritesheet symbol over the stage.
What I'd really like it so avoid using Adobe Animate entirely. Even if there's an approach that requires the use of Flex, I'd take it if it meant saying goodbye to graphically-designing.
using flash builder (flex) does not mean that good bye graphic! there is a relationship between Adobe Flash and any As3 Ide like FlashBuilder or FlashDevelop.
exporting movieclips and everything in library with .swc format, and then importing it by the IDE, read this
My goal is to embed all of the items in a single file other than the
main one. But I need to implement walking animation.
One thought I had is to set the main SWF's framerate to 7 FPS, then
use an Event.ENTER_FRAME handler to alternate between the walking
ones. Programmatically animating.
i dont undrestand! why 7 fps and also why Event.ENTER_FRAME
there might be a character movieclip, whit above frames in its time line, well! to playing any animation (for particular direction) you have to call mc.gotoAndPlay("walk_S"); then it will be played automatically, if you need lower frame rate, only select each frame by mouse pointer and then press [F5] in time line to insert a blank frame gape between keyframes.
as i said before, you must use a callback script at the end frame of the each loop animation like walk_s walk_ne ...
also idle animations must be called like it: mc.gotoAndStop("idle_s");

Frame by Frame animation AS3

This is for AS3 FlashDevelop, Basically I'm super new to this. The most I've done in AS3 coding is display multiple images on a single frame and parallax images.
However I want to know how to display embedded Bitmap (.png pictures) as frames one after another,
like frame 1 = embedded image 1 frame 2 = embedded image 2 (frame 1 is gone but 2 shows) frame 3 = embedded image 3 (and so on.)
and they would continuously play as an animation and stop at the first frame until I press play again
I believe I would use nextFrame, stop and gotoframe but don't know where and what I need to code, I heard of bitmapdata but I'm stuck on how to use it in purpose of animating frame by frame.
EDIT: No I'm not animating sprites, rather it's more like cartoon process where you'll go frame by frame of the image files, as one appear the previous one disappears.
You could iterate through each frame and add the images after you load them.
If you do addChild() it should add it to the current frame you're on. Load the next image with a Loader, place it down with addChild, nextFrame(), and repeat until you have all the images. Then when they're all loaded (from what I guess would be some list you'd have in an array or an xml) take the user to frame 1. You might want to do this inside of a movieclip while having that and a cover graphic on your main stage so the user doesn't see all of the images while they're being loaded and placed.
[More about adding display objects to frames]

Flash / pure AS3 preloader is seen after game is 100% loaded

first of all I want to tell that I know there are hundreds of similar questions, but most of them are for projects/games which are built for "on stage development".
I'm using pure as3 approach to develop games. I don't use*main timeline and my project has only 1 frame*.
On my main class's constructor, I only add preloader to the stage.
But still my preloader is seen only when the game is completely loaded.
My question is simple: "Why?" and "How can I fix this?"
-When I try to "uncheck" export as3 on frame 1, flash gives error.(because some of my classes are imported on the main class.)
-Even if I create second frame and put every contents of the game except preloader, the problem is still unsolved.
Thank you very much for spending your time to read this and help me.
-Ozan
To make the preloader, you either need two SWFs or at least two frames. Even FlashDevelop has an ability to use two frames, for this the directive [frame factoryClass="ClassName"] is used in main AS file before public class Main. This is the core limitation of Flash player, that is, it first loads the first frame, and only then it can display that frame. Since you've said you have only one frame, then your game has to be loaded 100% (1/1 frames) before you will see a thing.
There's more - if you are referencing a certain class on frame 1 via its class name, the class with all its dependencies is embedded in the same frame (the first), so you're screwed again. To bypass this, execute stepos 10 through 14 from this instruction to set the frame for classes to be 2 (replace 10 for 2 while executing the instruction), clear "export in the first frame" for all classes except your preloader, and add an instance of game's main class to keyframe 2. Then in preloader code perform proper cleanup and do gotoAndStop(2).

is there anyway that i can move to some frame in actionscript based on a random number from a dice?

here's the thing, i am actually new to actionscript and currently developing a a game in flash. the game is snakes and ladders. i have problems with regards to how to move the player avatar to the boxes of the game board. here's what i did. i made 100 frames, and with each frame is where the position of the avatar. (for example, frame 2 shows that the avatar is in box 2, etc).only thing is how do i make the frame move depending on a random number given by the dice.?
for example if i was originally in frame 2, and the dice gave a random number of 5, how do i get to frame 7? like playing the frames 3 - 6 and stopping at frame 7?
To move to a specified frame, invoke gotoAndStop() with a frame number as parameter. Of course, it can be calculated, and you can refer to movieclip's current frame via currentFrame property.
The manual

How can I send control of the playhead back to a parent timeline from a movieclip using createJS?

I'm making a multi-part introductory animation for a game. It works when I preview in Flash, but not when I export using the CreateJS toolkit to get HTML5 output.
On my scene's timeline, I have this.stop(); on the first frame, as well as a movie clip that contains several seconds of animation (and which may have to change in length as we develop).
My second frame is labeled "sc2" and I would like the animation to pick up there when the first movieclip is finished. To accomplish this, I went into the first movie clip and put this on the last frame:
_parent.gotoAndPlay("sc2");
This works fine in Flash, but perhaps I can't use the _parent object in JS? Is there an alternative way to access the flow of control or another way to accomplish this? My goal is to avoid doing animation on the main timeline and to control the flow by scripting there so that if the length of the individual sections of animation changes, I don't have to change the start and end frames of the various sections in several places.