Question

Is it possible to write code in a Flex application that will only be run in a debug build, or when running through the debugger? Does Flex provide a way to actually remove code entirely from release builds, like C-style #defines?

The app is not necessarily running in a web page.

Was it helpful?

Solution

You can do conditional compilation like this:

CONFIG::debugging {
    // this will be removed if CONFIG::debugging resolves to false at compile time
}

And then add this to the compiler flags:

-define+=CONFIG::debugging,true

for debug builds, and

-define+=CONFIG::debugging,false

for release builds. CONFIG and debugging can be anything, like MY_AWESOME_NAMESPACE and fooBar, it doesn't matter.

Read more here: Using conditional compilation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top