Example 1 (normal embeds):
Example 2 (assets module):
Some time ago one of my coworkers pointed me to a blog post that was giving suggestions to reduce the compilation time of a Flex project. Since we had long compilation times for our project at work, I decided to give it a try. The option that I chose was putting all the embeds inside a Flex module instead of embedding the assets directly inside each single source file. So, before testing the solution on the big project, I prepared a couple of small sample applications to test the difference and see if it was worth trying.
First of all, let’s briefly talk about the problem. Flex compiler can become slow if it has to embed a lot of assets in the application. This can be an issue if the application is particularly big. It seems that even if you change a single source file, the assets have to be embedded again to recompile everything. So, how can we avoid this? Using an assets module, and I’m going to call this module AssetsModule (quite straightforward).
In a standard application, when you want to embed an asset you have something like this:
<mx:Image source="@Embed(source='assets/myimage.png')"/>
With the usage of an assets module, you will have something like this:
<mx:Image source="{ModulesManager.getInstance().assets.myimage}"/>
To make our solution work, we need to make sure that there are no dependencies between the class that contains all the embeds in the module and the normal classes of the application. An interface is the right choice to achieve our goal. Read the rest of this entry »

Recent Comments