-
Notifications
You must be signed in to change notification settings - Fork 5
assetloader
This utility allows you to easily load external assets into your application. All the assets which are loaded by the AssetLoader
are stored and can be retrieved at any time. This can be done by retrieving the asset by it's url or unique id.
The AssetLoader
also allows you to load a group of assets at once. Therefore you will get a Group
returned instead of an single Asset
. That Group
will have as well as the Asset
an unique id you can use to retrieve it at another point within your application.
You can map the dependencies of AssetLoader
by using the static method mapDependencies
of Utilities
:
Utilities.mapDependencies( commandMap, [ Utilities.ASSET_LOADER ]);
After mapping the dependencies, you can inject the following values:
IAssetLoader
This can be done by calling the load
method:
assetLoader.load( 'asset.swf', onLoadProcess );
The following AssetLoaderEvent's
are dispatched to your callback method:
AssetLoaderEvent.ASSET_ERROR
AssetLoaderEvent.ASSET_PROGRESS
AssetLoaderEvent.ASSET_COMPLETE
This can be done by calling the loadGroup
method:
var assets: Array = [ 'asset.swf', 'asset.xml', 'asset.css', 'asset.mp3' ];
assetLoader.loadGroup( assets, onLoadProcess );
The following AssetLoaderEvent's
are dispatched to your callback method:
AssetLoaderEvent.GROUP_ERROR
AssetLoaderEvent.GROUP_PROGRESS
AssetLoaderEvent.GROUP_COMPLETE
Note: While the AssetLoader
is loading your multiple assets, you will also receive the AssetLoaderEvent's
of a single asset.
The AssetLoader
automatically assigns the right asset class by checking the extension of the asset. The following type's are currently supported:
-
BitmapAsset
- png
- gif
- jpg
- jpeg
-
DisplayObjectAsset
- swf
-
SoundAsset
- mp3
- wav
- aif
-
CSSAsset
- css
-
XMLAsset
- xml
Note: If the extension is not recognized, a default Asset
will be assigned.