sign up!

Are you interested in learning, then sign up to be notified about new tutorials.


helpfull links

website solutions

Do you need a website?
We can have you online in 24 hrs for less then $100

master flash

Are you looking to learn flash? If so you need to check out Flash, the Information you need. You will find all of these tutorials, source files and more...

Get your copy today!

Flash, This Information you need

a few friends

follow Us On

FrenchSquared on Linked in

FrenchSquared on Twitter

Frenchsquared on Facebook

Flash Tutorial, Repeat Actions

At times in Flash CS3, CS4 and ActionScript you will want to perform an action continuously. You may need to see if a movie is playing or if an object has hit another object. Or, perhaps you want to move an object from piont a to b.

In Flash CS3 and CS4 The Event.Enter_Frame is the line you will need. Event.ENTER_FRAME tells Flash to do this or that for every frame in the movie. This continuous action will happen even if the time line is stopped. It will happen as often as your frame rate is set for. Meaning if you run the movie at 30 frames per second then the Event.ENTER_FRAME will happen 30 times per second.

Using Enter_Frame

Once again in this Flash CS3 Tutorial some of the work is done for you. I have created an image of a car and the background of the street. I have already labeled the image of the car as car_mc. You just need to add the ActionScript 3.0. Select the first frame on the actions layer and create a new function using Event. Add the code from the example. Go ahead and press Control-Enter to see the movie in action.

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

function drive (yourEvent:Event):void {

car_mc.x += 5

car_mc.addEventListener(Event.ENTER_FRAME, drive)

If everything is correct the car will move down the street. In this Flash CS3 Tutorial, You set the function drive to run once on every key frame by using the Event.ENTER_FRAME method. You then added 5 pixels to the location of car_mc every time the function was executed. Thus, making the car move down the street. You can speed the car up by speeding up the frame rate or by increasing the amount of pixels the car moves. You need to know that the function will continue to run even after the car has left the stage. Therefore, you need to end the function if there is no longer a need for it, or you are just wasting processing power. To remove an event listener us the removeEventListener method.

function drive (yourEvent:Event):void {

car_mc.x += 5
if (car_mc.x >= 600){
car_mc.removeEventListener(Event.ENTER_FRAME, drive)

car_mc.addEventListener(Event.ENTER_FRAME, drive)

In the example I added an if statement that checks to see if the car has moved more then 600px. Since the stage is 700px, the car should stop at the edge of the stage. You can change the 600 to any number you want. I left it less then the stage width so you could actually see the car stop.

Press Control-Enter and test your movie.


In Flash CS3 and CS4 ENTER_FRAME is not the only way to coninually control an object. You can also create a timer. In the next part of this Flash Tutorial let’s move the Plane with a timer. This code is a little different in that you will need to create a variable. In Flash CS3 and CS4 you create a variable with the var tag. So in this case you are going to create the variable yourTimer. You are then going to Data Type it as a Timer, because it is part of proper coding. Next, you are going to set the constructors of the timer. The constructor takes two parameters, the first is a number in milliseconds and the second number is the number of intervals. You do not have to use the second parameter, but without it the timer will run until you stop it. That means, the timer you just created will be called every 10 milliseconds, and it will be called 170 times. 170 is just long enough to get the plane off the stage. You will want to increase it because the shadow is still on the stage. I stopped it a little sooner so you could actually see the plane stop. The rest of the code is basically the same. I added plane_mc.y -= 1 so the plane would not fly straight across the stage. You can play with these numbers as you wish to control the speed and distance the objects travel.

var yourTimer:Timer=new Timer(10,170)

function fly (yourEvent:TimerEvent):void {

plane_mc.x -= 5
plane_mc.y -= 1

yourTimer.addEventListener(TimerEvent.TIMER, fly

There are a few other event handlers that you should be aware of, but I will let you explore them on your own.

updateAfterEvent - you can use this to force Flash CS3 to refress the display if you object is moving faster then the frame rate. updateAfterEvent, will result in smoother motion.

TimerEvent.TIMER_COMPLETE - you can track the end of the timer with the TIMER_COMPLETE event handler, thus being able to start another action.

Download Tutorials