Ted Patrick > { Events & Community } > Adobe Systems


Flex - The Wizard behind the Curtain

Flex MXML is translated into an ActionScript Class before it is compiled into SWF. The easiest way to learn the deeper side of Flex is to modify your installation to keep generated actionscript. You will learn more about Flex than you ever wanted to know.

I learn by doing and this feature of Flex has allowed me to learn the deeper side of Flex. It allows you to see how Flex application internals work and allows you to explore the deeper APIs within the Flex Framework. Lets face it, it is one thing to write MXML, but quite another to bend Flex to work they way you want.

Exploring Flex 101 - How to turn on "keep-generated-as":


1. Locate this file:
{FLEX INSTALL}/WEB-INF/flex/flex-config.xml

2. Locate the XML tag "keep-generated-as" and modify the value to 'true'

3. Restart Flex


Now whenever an MXML application is compiled, the generated AS file will remain on the file system like so:

MyApp.mxml
MyApp-generated.as

Open the generated AS file and be prepared for a jolt of development reality. It is so nice to locate "The wizard behind the curtain".

Cheers,

Ted ;)

7 Responses to “ Flex - The Wizard behind the Curtain ”

  1. # Anonymous Scott Barnes

    Actually, along these lines if you were to open the .SWD (ie put FLEX debugging on) you'll see the original source code used - for those of you who want to know how certain controls look under the hood).  

  2. # Blogger Ted Patrick

    Scott,

    Ahhhh good one Scott. So this must explain your killer Flex skinning ability! Seriously, I have never seen anyone skin Flex like Scott can. He wrote a WinAmp Flex Theme that is almost unbelievable in quality.

    Cheers Scott!

    Ted ;)  

  3. # Blogger Avi

    Thanks for the tip Ted! Quick Q: I'm working with Flex Builder 2 Alpha 1, and I haven't been able to find the MyApp-generated.as file anywhere. I checked flex-config.xml (which was in "C:\Program Files\Macromedia\Flex Builder 2 Alpha 1\Flex Framework 2 Alpha 1\frameworks") and the key "keep-generated-actionscript" is already set to "true". I then built an app - tried both "run" and "debug" - but couldn't find the generated AS file anywhere.

    Do you know if this tip is applicable to Flex 2?

    Thanks!
    Avi  

  4. # Blogger Ted Patrick

    Avi,

    In Flex Builder 2 Alpha 1, the compiler setting seems to be broken. We will have to wait until a later release of Flex Builder 2 Beta until this feature is functioning.

    Plus its early on Flex 2 and the generated AS will most likely change wildly before release as features are added and optimizations made.

    I expect that keep-generated-as will make the final release of Flex Builder 2.0 given it has shiped with all prior Flex products and is avialable with CF7 too!

    Cheers,

    ted ;)  

  5. # Blogger Jason Hawryluk

    I would be interested in seeing some skinning example screen shots just to motivate me ;) Any change for this?

    Jason Hawryluk  

  6. # Anonymous Ryan Stewart

    Do you know if there's any way to set the path for the generated .as files?

    With a big project the generated .as files gets a little bit unwieldy.  

  7. # Anonymous Denis

    Actually you do have a chance to see a generated as code in Flex2. You shoud feed -keep-generated-actionscript directly to mxml compiler, ie "c:\Program Files\Macromedia\Flex Builder 2 Alpha 1\Flex Framework 2 Alpha 1\bin\mxmlc.exe -keep-generated-actionscript your.mxml".
    But well, you'll hardly get lucky when you see the code.  

Post a Comment



Jobs


Flex Jobs
city, state, zip


© 2008 Ted On Flex