Embedding Assets in Flex

Just working on another fun project here, and I thought that I would share something that I don’t see alot of Flex developers doing out there. That is organizing your image assests into asset classes as constants. It’s an easy way to keep everything organized, and reduce your overhead, because you can creatre classes that encapsulate a skin or graphics set for a particular task. If you want to learn how read on…

Encapsulating image assests in flex is easy. The trick is to organize the packages and classes in the right way. I like to create a package called assets. This is where I put all my sounds, images and assoc. creative. Inside the assets package, create a class for each UI section. For example you would have a class path like ‘assets.NavigationBar’ or ‘assets.InfoPanel’ . – whatever you need.

Inside the class, just embed your assets like this:

public static const BLUESTRIPES:Class;

Now that asset is availible to any class where you import the yourclass class to. Just reference the var BLUESTRIPES, or whatever the var name is.

Happy Coding!

About Curious Minds
We are a web development firm in New York and Chicago, providing development resources and consulting for websites and mobile apps since 2004.