HomeComputer programmingFlash/Actionscript Basics: If - Then - Else Statement Syntax

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

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" );
}

David Kirk
David Kirk
David Kirk is one of the original founders of tech-recipes and is currently serving as editor-in-chief. Not only has he been crafting tutorials for over ten years, but in his other life he also enjoys taking care of critically ill patients as an ICU physician.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!