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 Rotation 360 Degree Animation Tutorial (1)

This Flash ActionScript tutorial show how to use rotation property to do a single round rotation animation.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

Sometimes you only wish to rotate a Flash MovieClip for 360 degree for one time only. There are many methods to do this with Flash ActionScript. We will discuss two methods to do this rotation animation. The first method is a bit more complicated while the second method is a bit more straight forward.

Let's discuss the first method. The completed Flash Movie of this tutorial is shown as above. You can play around to see how it works.

Flash ActionScript Codes:

// Declare a Boolean variable - uGo
// Set uGo to false at the beginning
var uGo:Boolean = false;

 

// Add Listener to the Rotate Button
rotate_btn.addEventListener(MouseEvent.MOUSE_DOWN, rotateButtonClicked);

 

function rotateButtonClicked(evt:MouseEvent):void {

// If not uGo (i.e. true)
if (uGo == false) {
// Add ENTER_FRAME Event Listener to the stage
addEventListener(Event.ENTER_FRAME, startRotate);

// Set uGo to true
uGo = true;
}

}

 

function startRotate(evt:Event):void {

// Call function rotateSquare
rotateSquare();

}

 

function rotateSquare():void {

// Rotate the MovieClip
square_mc.rotation += 10;
if (square_mc.rotation == 0) {// Display message
output_txt.text = "The rotation completed 360 deg.";

// Set uGo to false
// Therefore the square will be rotated when the Rotate button clicked again.
uGo = false;

// Remove Listener so that the square will stop rotation
removeEventListener(Event.ENTER_FRAME, startRotate);

// Exit the function
return;
}// Display message
output_txt.text = "Current rotation angle: " + square_mc.rotation;

}

Download Flash Source File:

Flash Source File rotation-mc-3.fla

Remarks:

This Flash ActionScript tutorial shows how to do 360 degree rotation animation. Actually you can use a more simple method to do the same rotation animation . The next Flash ActionScript rotation tutorial will show you how.