I discovered a way to abuse Flash and ActionScript 3.0 that I think could be very useful for many cases.
- Put debug or testing-only code inside of trace statements (ie: trace(debugMode = true); )
- On publish and deployment, check the box labelled ‘omit trace statements’
What’s the benefit? Simple – you can write 10,000 lines of code for debugging purposes, and publish exactly zero of them, with a simple tick of a checkbox. The code footprint actually decreases too – your debug swfs will be many kB larger than the final published ones. Which means code that was never meant to be seen by users will stay that way.
- Override a domain-lock only while debugging
- Code cheats for local use that cannot be exploited online (since the related functions will be empty)
- Prevent your debug-console with private, secure variables from ever being released, even in part
- Wrap calls to the initialization of entire classes in trace statements (like development tools and level builders), then prevent them from being compiled with the SWF.
- You can build a massively secure Flash file that is specifically designed to work only on a secure server, and with no changes to configuration or code, have a massive local testbed that works differently while you’re building and debugging it.
I intend to use it for the domain-lock method for now. My files will always work locally and on my server, but break anywhere else. I like that.