Ternary / Conditional Operator in Actionscript 3

Like in many programming languages, Actionscript 3 allows for use of the ternary operator ?:

Let’s take a normal if statement as an example:

1
2
3
4
5
6
7
8
if( score == 10)
{
    win = true;
}
else
{
    win = false;   
}

This could be written in a different way using the ternary operator:

1
win = (score == 10) ? true : false;

So the syntax is: Expression ? statement : statement

Super Fast: How to Add a Drop Shadow

Adding a dropshadow effect to a Display Object in Actionscript 3 is really easy. In Actionscript 3, Display Objects such as MovieClips have a property called filters.

To apply a drop shadow to your MovieClip, you must first import the DropShadowFilter. Then create a DropShadowFilter instance. Lastly, assign your new filter to the MovieClip’s filters property: