How can you programmatically determine if a Flex application is running in debug mode?

Is it possible to write code in a Flex application that will run only in the debug assembly or when launched through the debugger? Does Flex provide a way to really completely remove code from releases, such as C-style #defines?

The application does not necessarily work on the web page.

+5
source share
1 answer

You can do conditional compilation as follows:

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 collections and

-define+=CONFIG::debugging,false

for releases. CONFIGand debuggingcan be anything, for example MY_AWESOME_NAMESPACEand fooBar, it does not matter.

: .

+10

All Articles