My Name Is Rich

Icon

Flash Tip: Conditional Compiling

Debuging is a craft in it’s own and it’s always helpful to find new tips and tricks. So, I’m writing to post about a new trick for helping us Flash coders debug our sweet, buggy code. Adobe put in a new feature in Flash CS4 called Conditional Compiling and you can read more about it from InsideRIA’s article.

The basic idea is that you can use a compiler constant called CONFIG::Debug to tell the compile when to run some code. If the constant is set to true it’ll be run if it’s set to false then it won’t. Simple, right? Before you start coding you’ll want to go into your Actionscript 3 settings and click on the last tab surprisingly called “Config constants”. Here you can create the constant and set it’s value.

Now that you are all set you you can then use code such as this to see it in action.

1
2
3
4
5
6
7
8
9
var val:int = 0;
for (var i:int = 0; i < 200; i++)
{
    val += i * .5;
    CONFIG::Debug
    {
        trace(val);
    }
}

And that’s it. It’s a small tip but one that I’ll be definitely using from now on in my projects. If you want to see another simple example I’ve put up a zip file located here for your viewing pleasure.

About Me

My name is Richard Perez and I am an alumni of Rochester Institute of Technology. This is my personal blog where I like to post about anything that insterests me. Which can range from design, programming, family, and tech gadgets. Currently, I work at HZDG in New York City as an Interactive Flash Developer. I love design and combining that with flash makes my day ten times better.

Categories

Calendar

September 2010
M T W T F S S
« Mar    
 12345
6789101112
13141516171819
20212223242526
27282930