Flash/Actionscript Basics: If - Then - Else Statement Syntax

Contributor Icon Contributed by davak Date Icon May 28, 2006  
Tag Icon Tagged: Computer programming

Creating a basic if - then statement in flash or actionscript is easy. Here is the correct syntax.


The basic syntax is the following:

if (condition)
{
statement(s);
}

Here is an actual working example. If the variable userInput contains data, the value will be sent to the trace command.

if (userInput != undefined)
{
trace("Input is " + userInput);
}

Adding an else section is not much harder:

if (userInput != undefined)
{
trace("Input is " + userInput);
}
else
{
trace("Input is unknown" );
}

Previous recipe | Next recipe |
 

 
close Reblog this comment
blog comments powered by Disqus