Package | starling.utils |
Class | public class AssetManager |
Inheritance | AssetManager ![]() |
If you load files from disk, the following types are supported:
png, jpg, atf, mp3, xml, fnt
Property | Defined By | ||
---|---|---|---|
scaleFactor : Number Textures that are created from Bitmaps or ATF files will have the scale factor
assigned here. | AssetManager | ||
useMipMaps : Boolean For bitmap textures, this flag indicates if mip maps should be generated when they
are loaded; for ATF textures, it indicates if mip maps are valid and should be
used. | AssetManager | ||
verbose : Boolean When activated, the class will trace information about added/enqueued assets. | AssetManager |
Method | Defined By | ||
---|---|---|---|
AssetManager(scaleFactor:Number = -1, useMipmaps:Boolean = false) Create a new AssetManager. | AssetManager | ||
addSound(name:String, sound:Sound):void Register a sound under a certain name. | AssetManager | ||
addTexture(name:String, texture:Texture):void Register a texture under a certain name. | AssetManager | ||
addTextureAtlas(name:String, atlas:TextureAtlas):void Register a texture atlas under a certain name. | AssetManager | ||
dispose():void Disposes all contained textures. | AssetManager | ||
enqueue(... rawAssets):void Enqueues one or more raw assets; they will only be available after successfully
executing the "loadQueue" method. | AssetManager | ||
getSound(name:String):Sound Returns a sound with a certain name. | AssetManager | ||
getSoundNames(prefix:String):Vector.<String> Returns all sound names that start with a certain string, sorted alphabetically. | AssetManager | ||
getTexture(name:String):Texture Returns a texture with a certain name. | AssetManager | ||
getTextureAtlas(name:String):TextureAtlas Returns a texture atlas with a certain name, or null if it's not found. | AssetManager | ||
getTextureNames(prefix:String, result:Vector.<String> = null):Vector.<String> Returns all texture names that start with a certain string, sorted alphabetically. | AssetManager | ||
Returns all textures that start with a certain string, sorted alphabetically
(especially useful for "MovieClip"). | AssetManager | ||
loadQueue(onProgress:Function):void Loads all enqueued assets asynchronously. | AssetManager | ||
playSound(name:String, startTime:Number = 0, loops:int = 0, transform:SoundTransform = null):SoundChannel Generates a new SoundChannel object to play back the sound. | AssetManager | ||
purge():void Removes assets of all types and empties the queue. | AssetManager | ||
removeSound(name:String):void Removes a certain sound. | AssetManager | ||
removeTexture(name:String, dispose:Boolean = true):void Removes a certain texture, optionally disposing it. | AssetManager | ||
removeTextureAtlas(name:String, dispose:Boolean = true):void Removes a certain texture atlas, optionally disposing it. | AssetManager |
scaleFactor | property |
scaleFactor:Number
Textures that are created from Bitmaps or ATF files will have the scale factor assigned here.
public function get scaleFactor():Number
public function set scaleFactor(value:Number):void
useMipMaps | property |
useMipMaps:Boolean
For bitmap textures, this flag indicates if mip maps should be generated when they are loaded; for ATF textures, it indicates if mip maps are valid and should be used.
public function get useMipMaps():Boolean
public function set useMipMaps(value:Boolean):void
verbose | property |
verbose:Boolean
When activated, the class will trace information about added/enqueued assets.
public function get verbose():Boolean
public function set verbose(value:Boolean):void
AssetManager | () | Constructor |
public function AssetManager(scaleFactor:Number = -1, useMipmaps:Boolean = false)
Create a new AssetManager. The 'scaleFactor' and 'useMipmaps' parameters define how enqueued bitmaps will be converted to textures.
ParametersscaleFactor:Number (default = -1 )
| |
useMipmaps:Boolean (default = false )
|
addSound | () | method |
public function addSound(name:String, sound:Sound):void
Register a sound under a certain name. It will be availble right away.
Parameters
name:String | |
sound:Sound |
addTexture | () | method |
public function addTexture(name:String, texture:Texture):void
Register a texture under a certain name. It will be availble right away.
Parameters
name:String | |
texture:Texture |
addTextureAtlas | () | method |
public function addTextureAtlas(name:String, atlas:TextureAtlas):void
Register a texture atlas under a certain name. It will be availble right away.
Parameters
name:String | |
atlas:TextureAtlas |
dispose | () | method |
public function dispose():void
Disposes all contained textures.
enqueue | () | method |
public function enqueue(... rawAssets):void
Enqueues one or more raw assets; they will only be available after successfully executing the "loadQueue" method. This method accepts a variety of different objects:
png, jpg, atf, mp3, fnt, xml
(texture atlas).static
embedded assets.Parameters
... rawAssets |
getSound | () | method |
public function getSound(name:String):Sound
Returns a sound with a certain name.
Parameters
name:String |
Sound |
getSoundNames | () | method |
public function getSoundNames(prefix:String):Vector.<String>
Returns all sound names that start with a certain string, sorted alphabetically.
Parameters
prefix:String |
Vector.<String> |
getTexture | () | method |
public function getTexture(name:String):Texture
Returns a texture with a certain name. The method first looks through the directly added textures; if no texture with that name is found, it scans through all texture atlases.
Parameters
name:String |
Texture |
getTextureAtlas | () | method |
public function getTextureAtlas(name:String):TextureAtlas
Returns a texture atlas with a certain name, or null if it's not found.
Parameters
name:String |
TextureAtlas |
getTextureNames | () | method |
public function getTextureNames(prefix:String, result:Vector.<String> = null):Vector.<String>
Returns all texture names that start with a certain string, sorted alphabetically.
Parameters
prefix:String | |
result:Vector.<String> (default = null )
|
Vector.<String> |
getTextures | () | method |
public function getTextures(prefix:String, result:Vector.<Texture> = null):Vector.<Texture>
Returns all textures that start with a certain string, sorted alphabetically (especially useful for "MovieClip").
Parameters
prefix:String | |
result:Vector.<Texture> (default = null )
|
Vector.<Texture> |
loadQueue | () | method |
public function loadQueue(onProgress:Function):void
Loads all enqueued assets asynchronously. The 'onProgress' function will be called with a 'ratio' between '0.0' and '1.0', with '1.0' meaning that it's complete.
Parameters
onProgress:Function — function(ratio:Number):void;
|
playSound | () | method |
public function playSound(name:String, startTime:Number = 0, loops:int = 0, transform:SoundTransform = null):SoundChannel
Generates a new SoundChannel object to play back the sound. This method returns a SoundChannel object, which you can access to stop the sound and to control volume.
Parameters
name:String | |
startTime:Number (default = 0 )
| |
loops:int (default = 0 )
| |
transform:SoundTransform (default = null )
|
SoundChannel |
purge | () | method |
public function purge():void
Removes assets of all types and empties the queue.
removeSound | () | method |
public function removeSound(name:String):void
Removes a certain sound.
Parameters
name:String |
removeTexture | () | method |
public function removeTexture(name:String, dispose:Boolean = true):void
Removes a certain texture, optionally disposing it.
Parameters
name:String | |
dispose:Boolean (default = true )
|
removeTextureAtlas | () | method |
public function removeTextureAtlas(name:String, dispose:Boolean = true):void
Removes a certain texture atlas, optionally disposing it.
Parameters
name:String | |
dispose:Boolean (default = true )
|