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 if Conditional Statement

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

The most commonly used conditional statement in computer programming should be the if statement. The if statement is relatively easy to read and understand. The following diagram illustrate the basic structure of a if statement.

If conditional statement

Flash ActionScript Codes:

// Declare the variable (myAge)
// Assign int to the data type of myAge
// Store the value of my Age
var myAge:int = 30;

 

// Test the age by using the If conditional statement
if (myAge >= 50){
output_txt.htmlText = "You enter " + String(myAge) + ". Yes! I am 50 or older than 50!";
} else if (myAge < 30){
output_txt.htmlText = "You enter " + String(myAge) + ". Yes! My age is younger than 30!";
} else {
output_txt.htmlText = "You enter " + String(myAge) + ". Yes! I am older than 29 and younger than 50!";
}

Download Flash Source File:

Flash Source File if-condition-statement.fla

Comparison Operators

The following are some commonly used comparison operators:

Comparison
Operator
Meaning Example
== Equal to if (myAge == 30) {
!= Not equal to if (myAge != 25) {
< Smaller than if (myAge <50) {
<= Smaller than or Equal to if (myAge <= 20) {
> Greater than if (myAge > 55) {
>= Greater than or Equal to if (myAge >= 60) {

 

Remarks:

If there is only one conditional need to be tested, the else if conditional is not required.