Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

Flash ActionScript Loop (Repeat) Animation Tutorial

This Flash ActionScript tutorial shows how the flash animation can be played again and again (loop animation).

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

Most flash animation on the Internet are usually loop animation, i.e. animation repeat again and again. The animation is simply repeat again and again. This Flash ActionScript tutorial shows how to use ENTER_FRAME event to do such animation.

The complete Flash Movie is shown as above, you may try how it works before you start this tutorial. Click on the above flash movie to select it to start. Click on the Play button to turn on the animation. Click on the Stop button to stop the animation.

Flash ActionScript Codes:

function moveFootball(evt:Event):void {

//Use ENTER_FRAME event to fire action for every frame.
stage.addEventListener(Event.ENTER_FRAME, moveFootball);
//Set the frame rate
stage.frameRate = 15;

//Display location of the Footabll in the Message TextField.
output_txt.text = "Location of ball: " + football_mc.x + "," + football_mc.y;

//Keep track the location of the ball
//If location small than the Stage Width, move to right by 1 pixel
//otherwise move back to the left of Stage by 10 pixel
if (football_mc.x < 512) {
football_mc.x += 1;} else {football_mc.x = -10;}



//Call the moveBall function when movie starts.
//Therefore the football will start moving when movie starts.

function stopFootball(eve:Event):void {

stage.removeEventListener(Event.ENTER_FRAME, moveFootball);



//Button to stop the football
stop_btn.addEventListener(MouseEvent.CLICK, stopFootball);


//Button to move the football
play_btn.addEventListener(MouseEvent.CLICK, moveFootball);

Download Flash Source File:

Flash Source File enter-frame-5.fla


You should noticed that the football is always enter and leave the stage in the same position. This kind of flash animation is a bit boring because the animation simply repeat again and agin. This would be more wonderful if the ball enter and leave the stage in a random position. In other words, the animation is not just repeat again and again, it is changing all the time. The next Flash ActionScript tutorial will show how to use ENTER_FRAME to do such animation.