If you use Flex Builder you will no doubt have taken advantage of the handy [Embed] metadata tag to embed external files directly into a class. One thing that has always annoyed me slightly is the way the generated asset classes are all forced to extend Flex-specific classes such as mx.core.BitmapAsset, not a problem if you are using the Flex framework but what if you just want to use the FP10 SWC and avoid the Flex framework altogether?
No problemo.
Because the Flex asset classes do nothing more than extend native Flash classes (BitmapAsset extends Bitmap etc) you can create those Flex asset classes in your project library and Flex Builder will be more than happy to use them. For example, let us say we have created an ActionScript project, removed the Flex SDK from the Library Paths, and imported the FP10 SWC instead. What you do now is simply recreate the mx.core directory structure and create the required asset classes. Your bare-bones ActionScript project might look like this…
[font=courier new]Project[/font]
[font=courier new]Project / bin[/font]
[font=courier new]Project / src[/font]
[font=courier new]Project / src / mx[/font]
[font=courier new]Project / src / mx / core[/font]
[font=courier new]Project / src / mx / core / BitmapAsset.as[/font]
[font=courier new]Project / src / Main.as[/font]
...and the BitmapAsset class in that example would look like this…
package mx.core
{
import flash.display.Bitmap;
public class BitmapAsset extends Bitmap
{}
}
Done! You can now happy embed images into your classes without Flex Builder moaning, and you can do the same thing for any of the other asset classes such as ByteArrayAsset or SoundAsset etc.
- Log in or join for free to make a comment.


