Skip to content
moorinteractive edited this page Jan 15, 2011 · 3 revisions

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.

Dependencies

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

Loading a single asset

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

Loading a group of assets

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.

Type of assets

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.

Clone this wiki locally