eHow launches Android app: Get the best of eHow on the go.

How To

How to Write an If - Else Statement in Adobe Flash ActionScript 3.0

Member
By Mike
User-Submitted Article
(0 Ratings)
Write an If - Else Statement in Adobe Flash ActionScript 3.0
Write an If - Else Statement in Adobe Flash ActionScript 3.0

What would any programming language without the ability to test a condition and then act upon that test. Adobe's Flash ActionScript 3.0 programming language gives that ability with the the IF-ELSE statement.

Here is how you write an IF-ELSE statement in Adobe's Flash ActionScript 3.0 programming language.

Difficulty: Easy
Instructions

Things You'll Need:

  • Adobe Flash CS4
  1. Step 1

    The IF-ELSE statment is read as "if some condition is true then do something, if the condition is not true, then do something else". The first line of the IF-ELSE statement is written as:

    if (some condition) {

    That's "if" open parenthesis, followed by the condition you want to test, a closed parenthesis, then an opening curly brace which signifies the code after that brace is to be executed if the "some condition" is true.

  2. Step 2

    The next series of lines is the code to be executed if the condition is true. It can be a series of lines of code, a call to a function and so on. So you code now looks like:
    if (some condition) {
    Some code
    }

    When you are finished with the code that you want executed if the condition is true you simply end it with a closed curly brace as shown above.

  3. Step 3

    Finally, although not required, we add in our ELSE statement. This gets exceuted if the condition in the steps above is false.

    else {
    execute this code if condition is not true
    }

    Just like the first part you open your code block with an open curly brace, put in your code and close it with a closed curly brace. So you final code looks like this:

    if (some condition) {
    code
    }
    else {
    more code
    }

Post a Comment

Post a Comment
  • Have you done this? Click here to let us know.
I Did This

Related Ads

Computers
Alexia Petrakos,

Meet Alexia Petrakos eHow's Computers Expert.

Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

eHow Computers
eHow_eHow Technology and Electronics