Ripping out non-demo code with conditional compilation?

Hi- as the title indicates, I’m looking to upload a flash demo of my game to the web. Basically, I use a DEMO_MODE=true flag to alter the game. But I’d like to protect against someone de-compiling the game and simply un-setting that flag.

So I’d also like to use the DEMO_MODE flag to rip out certain segments of code that I know the demo won’t use, forcing the game to crash if someone circumvents the demo settings. Something like:

#if !(DEMO_MODE)
    //protected, non-demo code goes here
#endif

It seems like this would work but I’m also worried it’s too simple of a solution. Is this possible to reverse in any way? If they decompile the .swf, they’re just going to get the swf/actionscript assets. Even IF they could reverse that all the way back to HaXe, it’s not like they can dig that non-demo code up from anywhere. It just isn’t in the build to begin with.

Any caveats that I’m missing?

This will prevent the source from ever being compiled – it should behave as if you deleted those portions before going through the compiler, so it should not be visible to a decompiler at all :wink:

That’s what I was hoping for, thanks!