James Law’s Joint

flex builder tip

July 28, 2008 · Leave a Comment

I have been using Flex builder on and off for the last 6 months or so, and I thought I’d share something that I (perhaps embarassingly) just realized. I have wasted countless hours of debugging as I didn’t understand an aspect of how flex builder builds the output swf file.

Background:

When you create a flex builder project, you create what adobe calls “applications”. These are usually in the form of .mxml files. Simple applications might have all their code in the .mxml itself. More complicated applications might augment this application.mxml file with a number of plain actionscript classes. For instance, if you’re using an flex MVC framework like parsley, cairngorm, pureMVC.

All artifacts declared an “application” or a “module” become a .swf file. The .swf has all the mxml, actionscript, and other resources to run within the adobe flash player.

So?

So what you say?

The flex builder compiler (I believe it is using mxmlc behind the scenes) only includes files that are reachable from what is declared as an application.

In the above image, you can see my application.mxml file. This seems to drive the flex builder compilation process.

Only actionscript classes that have a declaration will be included in the output swf file. This is probably done to minimize the size of the swf, which makes load times lower.

If you come from a java/eclipse background, you expect anything labeled source to get built. This is simply not the case with FlexBuilder. The only things that get built are those applications/modules that its been told to, and any actionscript that is reachable from them.

Why this matters?

If you’re using remoting (blaze ds), or using DI, it is likely your application may NOT have direct references to your action script classes. Thus, in the case of remoting, you may find your objects are not being deserialized to the appropriate AS3 class on the client, but you won’t know why.

How to fix:

One way is to put a variable declaration for each class inside your application class. If someone has a better way please let me know via comments. I’ve searched for hours in google land to no avail.

PS> Is there a free swf decompiler out there? So I can see what is actually being put into my swf files?

Categories: Uncategorized

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment