Posts tagged "actionscript example preprocessor"

Using a Pre-processor with ActionScript to define constants

Yesterday I posted some simple info on how to use the cpp pre-processor to pre-process ActionScript files. I showed how you can use the #ifdef directive to conditionally add / remove stuff from the final ActionScript file. However, cpp can do a lot more than just conditional section includes.

You can use the #define directive to define constants within your ActionScript file / class.

For example, lets look at a simple example:

Continue reading…

Pre-Processing ActionScript files / classes

One thing I often do in my code is create custom trace / output functions that recursively go through and print out properties. However, this requires that I add some custom code to my classes which I don’t really want in the final version.

So, I started exploring pre-processors that I could use to make it easier to add and remove debugging code. I first looked at m4. While it seems to be very powerful, it was overkill for what I needed, and looked to be very difficult to use. Christian Cantrell then suggested that I look at cpp, a C pre-processor. I checked it out, and it does exactly what I need, in an easy to learn and use syntax.

Continue reading…