Character animation in movie clip via actionscript


I am trying to make a movie in flash, and each character is its own movie clip symbol. I also have a variable for each character, to control the current animation running. I have one character in the movie, for now, and that movie clip symbol is called mann. It is just a simple draw, Im just testing this method out. Now, the first frame of the movie, has this action:

mann1_anim = 1;

that is the first time I use that variable, so then it will be created, right? anyway, then, the first frame of the mann movie clip symbol has this action:

while (mann1_anim == 1) { }

on that first frame, my man character only stands, so this action should do so that while the mann1_anim variable is 1, the man should just stand there, right?
Then, the 9th frame of the MOVIE, has this action:

mann1_anim = 2;

then something should happend in the action of the first frame of the mann movie clip symbol, because mann1_anim is no longer 1. Then the mann movie clip should start and play at frame 2, right?
From frame 9 of the MOVIE to frame 22, I have created a motion tween for the mann symbol. from right of the screen to the left. Then, in the 2nd frame of the mann MOVIE CLIP to the 3th frame, is the “walk to the left” animation. At the 3rd frame of the MOVIE CLIP, I have this action:

while (mann1_anim == 2) {

this should loop the walk to the left animation to frame 22 of the movie, cause in frame 22 of the movie, when the tween animation stops, is this action:

mann1_anim = 1;

so then, when the tween animation stops, the mann symbol should return to the stand animation (frame 1).

Well, that was a lot of explenation, and here is the problem.
When I test the movie, the mann runs its complete animation all the time! I don`t understand why, do you?

I have uploaded my work file(fla) here, it might help to understand better:)

Thanks a lot for your time and please help

Well, my friend… you have some problems here. I know how you feel because you’re obviously excited about this actionscript thing and you’re trying out some stuff. The code you wrote really has problems everywhere (sorry). Let’s get to what you were trying to do first.

  1. You wanted to show a man standing. After a while, you wanted to have the man move left and then stop. Correct?

If so, you need very little actionscript for that, you just have to work on your tweens. Quick example:

frame 1 through 36 (layer1)… man stands for 3 seconds (depends on frame rate)

frame 37 through 74 (layer2)… man walks left

frame 74 layer 2 (blank keyframe) insert the action stop(); so the man stops walking when he reaches destination.

I dont this it is wise for me to go through all your code at this time. Instead, I would strongly suggest that you follow the tutorials on this site. They are all very good and very easy to follow. Just start with the basics and you will be up and running in no time. It would also benefit you greatly to get a book on Actionscript, so you can understand the logic behind writing some of this code. You’ll be amazed at how fast you can pick it up.

Most people would recommend: Actionscript the Definitive Guide by Collin Mook. Although I dont think they have an MX version out yet (as of July 6th, 2002).

Good luck!

thanks for replying. Well, I see that you try to give me an easier way doing this, but say that I want my man to first stand for…10 frames, then I want him to walk to the left for 15 frames, and then I want him to stop for 5 frames, and then again walk to the left for 10 frames. In the movie I will need to run the same animations several times. So then it will be a little stupid to just copy the same walk frames again and again and again. So thats why I want to do it via actionscripts, so I can get a much more compressed and and much more clear set out for the movie.

Anyway, I tried another and maybe a bit easier way doing this with actionscript, so at frame 1-8, he just stand there, dosn`t move, cause frame 1 of the mann symbol has this script:


Then, frame 9-22 he has a motion tween to move him to the left. The name of the man symbol is mann. Frame 9 of the movie has this script:


in the man symbol, frame 2-3 is the walk left animation. frame 3 has this script:


so that the animation will loop.

Then, frame 22 of the movie has this script:


so the walk left animation will stop.
frame 1 of the man has this script:


the problem I get when I play the movie is that the animation of mann dosn`t change at all, he does his stand animation when he moves to the left.

what is wrong this time?

thanks for your time

anyone? I really need help with this, would make everething so much easier for my movie making