We all like to know a little more about what goes on under the hood of our favourite tools. Undocumented features and the like have a certain appeal that gets everybody excited.
Flex Builder 2 which is currently in public beta has a little known gem of a feature (for which documentation is scarse) which you can use to learn alot more about what Flex actually does under the hood to make all that mxml markup goodness into a working Flash movie. This compiler option did not work in the previous public alpha build.
The brains of Flex 2 lie in the compiler (AKA MXMLC) which internally converts all your mxml markup into Actionscript 3 classes ready for the next stage of the process which is Actionscript compilation. The Flex 2 compiler accepts certain arguments (or compiler flags) that allow you to change the way it operates slightly.
There are plenty of these compiler flags but my favourite has to be the option that tells MXMLC to keep all of the Actionscript 3 classes that it has generated as part of the project building process. You can then view these actionscript files to find out more about how Flex actually works.
The compiler flag i speak of is called -keep-generated-actionscript and you can turn it on in Flex Builder 2 for your own pleasure by doing the following:
- Right-click a Flex Project in the Navigator Panel.
- Select Properties from the Context Menu.
- Select Flex Compiler in the Properties Window.
- Enter -keep-generated-actionscript into the ‘Additional compiler arguments’ field.
- Click ‘OK’ to apply the changes.
- Build your Flex Project by clicking the Run button.
- Right-click your Flex Project again in the Navigator Panel.
- Choose Refresh from the Context-Menu.
- A new folder should appear under your Flex Project in the Navigator Panel, named ‘generated’
Inside the ‘generated’ folder lies the under the hood Actionscript 3 files that the compiler generates as an interim stage of the whole compilation process. Open them up and have a nosey as to what Flex 2 is actually doing under the hood to setup all the default component styles etc… it’s an awesome feature, lets hope they keep it in there.
Enjoy.
Thanks, Your tip put initil lights on the FLex.