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

Bring to Front Function

This one has been covered a million times on other sites but I thought I’d include it here anyway.

To move a MovieClip or other DisplayObject to the front of the stack, you can use the following function:

Annoying Adobe Illustrator Behavior Problem Solved

I am often given AI files (Adobe Illustrator) for the purpose of extracting assets for my flash projects. Over the past few months, I’ve been receiving a lot of files having been giving me this same issue.

How to Iterate The Properties of an AS3 Class

As you may have noticed, you can’t iterate over the properties of an Actionscript 3 class as if they were normal properties of a generic object, unless the class is dynamic of course.

here’s what I mean:

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: