I am in the process of creating a new - "lite" - version of a Flex application I created a while ago. I have been porting over many of the Classes and Components to a Flex Library Project that compiles an SWC file. Because both are Cairngorm applications, I'm not able to completely eradicate duplicate code, but it seems logical that I should be able to share assets - such as icons (PNG files). What is the best way to do this? I have tried including them in the SWC, but I can't figure out how to access them in the application. If you can help me figure that out, then my question will be answered. Any thoughts?
Here is and example of how I currently embed icons/images in my Flex application:
<mx:Script>
<![CDATA[
[Bindable]
[Embed(source="assets/icons/cancelIcon.png")]
private var cancelIcon:Class;
[Bindable]
[Embed(source="assets/icons/saveIcon.png")]
private var saveIcon:Class;
]]>
</mx:Script>
Thanks.
Might be a topic for a new question as others no doubt have a ton to add RE: Resources and performance in Flex).
In short, see from Adobe: http://tinyurl.com/nwe4yo and http://tinyurl.com/dlvjr3 - check out how to organize your web-app with RSLs to avoid bring the entire application down at once & making the user wait.
Also see cool code-level techniques for re-using resources at runtime efficiently in the ASDocs on BitmapAsset @ http://tinyurl.com/muy8do – Gabriel Jun 10 '09 at 22:22