| Package | km.core |
| Class | public final class AssetManager |
| Property | Defined by | ||
|---|---|---|---|
| messenger : EventDispatcher [static] Broadcasts a 'complete' or 'ioError' event when the loading process ends.
You can add a listener to the messenger to receive one of the events. | AssetManager | ||
| namePrefix : String [static] The asset name prefix to use.
Using a prefix makes it easier to handle a lot of assets that start with the same part. | AssetManager | ||
| suppressNotFoundError : Boolean = false [static] When set to true, no error is thrown when you try to get an asset that can't be found.
| AssetManager | ||
| Method | Defined by | ||
|---|---|---|---|
|
getAsset(name:String, usePrefix:Boolean = true):*
[static] Returns the specified asset.
| AssetManager | ||
|
getQueueCurrent():String
[static] Returns the name from the queue item that is currently being loaded.
| AssetManager | ||
|
getQueueCurrentPercentage():uint
[static] Returns the percentage loaded from the queue item that is currently being loaded.
| AssetManager | ||
|
getQueueLength():uint
[static] Returns the number of items the queue contains.
| AssetManager | ||
|
isAsset(name:String, usePrefix:Boolean = true):Boolean
[static] Returns true if the asset exists.
| AssetManager | ||
|
loadBinaries(... binaries):void
[static] Adds all specified binaries to the queue and starts loading them.
| AssetManager | ||
|
loadImages(... images):void
[static] Adds all specified images to the queue and starts loading them.
| AssetManager | ||
|
loadSounds(... mp3s):void
[static] Adds all specified sounds to the queue and starts loading them.
| AssetManager | ||
|
registerBitmapDataAsset(asset:BitmapData, name:String, area:Rectangle = null, usePrefix:Boolean = true):void
[static] Registers a BitmapData asset.
| AssetManager | ||
| messenger | property |
public static var messenger:EventDispatcher Broadcasts a 'complete' or 'ioError' event when the loading process ends.
You can add a listener to the messenger to receive one of the events.
import km.core.*;
AssetManager.loadImages('my1stImage.png', 'my2ndImage.png');
AssetManager.messenger.addEventListener('complete', loadComplete);
function loadComplete(e:Event){
play();
}
stop();
| namePrefix | property |
public static var namePrefix:String The asset name prefix to use.
Using a prefix makes it easier to handle a lot of assets that start with the same part.
If for example a lot of assets start with 'km.themes.classic.' you don't have to type
that all the time.
| suppressNotFoundError | property |
public static var suppressNotFoundError:Boolean = falseWhen set to true, no error is thrown when you try to get an asset that can't be found.
| getAsset | () | method |
public static function getAsset(name:String, usePrefix:Boolean = true):*Returns the specified asset. If the specified asset is a class, it will be registered automatically as an asset.
Parametersname:String |
|
usePrefix:Boolean (default = true) |
* |
| getQueueCurrent | () | method |
public static function getQueueCurrent():StringReturns the name from the queue item that is currently being loaded.
ReturnsString |
| getQueueCurrentPercentage | () | method |
public static function getQueueCurrentPercentage():uintReturns the percentage loaded from the queue item that is currently being loaded.
Returnsuint |
| getQueueLength | () | method |
public static function getQueueLength():uintReturns the number of items the queue contains.
Returnsuint |
| isAsset | () | method |
public static function isAsset(name:String, usePrefix:Boolean = true):BooleanReturns true if the asset exists.
Parametersname:String |
|
usePrefix:Boolean (default = true) |
Boolean |
| loadBinaries | () | method |
public static function loadBinaries(... binaries):voidAdds all specified binaries to the queue and starts loading them.
Parameters... binaries |
| loadImages | () | method |
public static function loadImages(... images):voidAdds all specified images to the queue and starts loading them.
Parameters... images |
import km.core.*;
var AM:Object = AssetManager;
AM.loadImages('button.png','checkbox.png');
var tf:TextField = new TextField();
tf.defaultTextFormat = new TextFormat('_sans');
tf.autoSize = 'left';
tf.x = 20;
tf.y = 20;
addChild(tf);
addEventListener('enterFrame', enterFrame);
function enterFrame(e:Event){
if (!AM.getQueueLength()){
removeEventListener('enterFrame', enterFrame);
removeChild(tf);
play();
} else {
tf.text = 'Loading asset : ' + AM.getQueueCurrent();
tf.appendText('\nAssets remaining : ' + AM.getQueueLength());
}
}
stop();
| loadSounds | () | method |
public static function loadSounds(... mp3s):voidAdds all specified sounds to the queue and starts loading them.
Parameters... mp3s |
| registerBitmapDataAsset | () | method |
public static function registerBitmapDataAsset(asset:BitmapData, name:String, area:Rectangle = null, usePrefix:Boolean = true):voidRegisters a BitmapData asset. This function gives you the freedom to register a BitmapData object created at runtime as an asset. The area parameter allows you to specify what part of the specified bitmap should be registered.
Parametersasset:BitmapData |
|
name:String |
|
area:Rectangle (default = null) |
|
usePrefix:Boolean (default = true) |