Export to GitHub

splinkresource - Assets.wiki


Just create a class and declare some public vars wich are annotated with embed tags. Don't forget to extend Sprite. Compile this single class into a swf and reference that swf in the configuration xml. Note that the source path within the embed tag is relative to the class. Here is an example:

First the class which embeds the assets: public class AssetRegister extends Sprite { [Embed(source="splink.jpg")] public var SplinkAsset:Class; }

It is good practice to create a seperate class with only constants to enable typesafe access to the assets. Note that it would be very unwise to use the AssetRegister class to hold the constants as this would cause all the assets which are embedded in AssetRegister to get compiled into the main swf which is what we wanted to avoid in the first place.

So, here is the constant class, note that the SplinkAsset String matches the SplinkAsset Class variable inside AssetRegister public class Assets { public static const SPLINK_ASSET : String = "SplinkAsset"; }

Here is the code for the resourcebundles configuration xml: <assets path="assets/"> <asset id="sample" src="assets.swf" filesize="0" /> </assets>

And finally we can retrieve the asset in our application: var asset : DisplayObject = ResourceProvider.instance().getAssetById(Assets.SPLINK_ASSET)