Packagegs.managers
Classpublic final class AssetManager

The AssetManager class is a helper that stores all assets loaded by any Preloader and can get assets from any swf library.

Examples are in the guttershark repository.

See also

gs.preloading.Preloader


Public Properties
 PropertyDefined by
  lastLibraryName : String
[static][read-only] The last libraryName that was used to register an object.
AssetManager
Public Methods
 MethodDefined by
  
addAsset(libraryName:String, obj:String, source:* = null):void
[static] Register an asset in the library.
AssetManager
  
dispose():void
[static] Purge all assets from the library.
AssetManager
  
getAsset(libraryName:String):*
[static] Get any stored asset.
AssetManager
  
getBitmap(libraryName:String, smooth:Boolean = true):Bitmap
[static] Get a Bitmap.
AssetManager
  
getBitmapFromFZip(fzip:FZip, filename:String, receiver:Function, timeout:Number = 100):void
[static] Send a bitmap from an fzip file to a receiver function.
AssetManager
  
getBitmapFromSWFLibrary(swfLibraryName:String, bitmapLinkageId:String, smooth:Boolean = true):Bitmap
[static] Get a bitmap from a swf library.
AssetManager
  
getClass(exportName:String):Class
[static] Get a Class.
AssetManager
  
getClassFromSWFLibrary(swfLibraryName:String, classNameInLibrary:String):Class
[static] Get a class from a swf library.
AssetManager
  
getFLV(libraryName:String):FLV
[static] Get an flv instance.
AssetManager
  
getFLVMetaData(libraryName:String):Object
[static] Get an FLV's meta data.
AssetManager
  
getFLVXMPMetaData(libraryName:String):Object
[static] Get an FLV's XMP meta data.
AssetManager
  
getFont(exportName:String):Font
[static] Get a font.
AssetManager
  
getFontFromSWFLibrary(swfLibraryName:String, fontLinkageId:String):Font
[static] Get a font from a swf library.
AssetManager
  
getFZip(libraryName:String):FZip
[static] Get an FZip.
AssetManager
  
getJSON(libraryName:String):Object
[static] Returns a JSON object that was loaded with a preloader.
AssetManager
  
getMovieClip(exportName:String):MovieClip
[static] Get a movie clip.
AssetManager
  
getMovieClipFromSWFLibrary(swfLibraryName:String, classNameInLibrary:String):MovieClip
[static] Get a movie clip from a swf library.
AssetManager
  
getNetStream(libraryName:String):NetStream
[static] Get a loaded asset as a NetStream.
AssetManager
  
getSound(libraryName:String):Sound
[static] Get a sound.
AssetManager
  
getSoundFromSWFLibrary(swfLibraryName:String, soundLinkageId:String):Sound
[static] Get a sound from a swf library
AssetManager
  
getSprite(exportName:String):Sprite
[static] Get a sprite.
AssetManager
  
getSpriteFromSWFLibrary(swfLibraryName:String, classNameInLibrary:String):Sprite
[static] Get a sprite from a swf library.
AssetManager
  
getStyleSheet(libraryName:String):StyleSheet
[static] Get a style sheet that was preloaded from a css file.
AssetManager
  
getSWF(libraryName:String):Loader
[static] Get a loaded asset as a SWF.
AssetManager
  
getText(libraryName:String):String
[static] Get an asset that was loaded as text.
AssetManager
  
getXML(libraryName:String):XML
[static] Get a loaded asset as XML.
AssetManager
  
isAvailable(libraryName:String):Boolean
[static] Check to see if an asset is available in the library.
AssetManager
  
isNetStreamLoaded(libraryName:String):Boolean
[static] Check whether or not a net stream is 100% loaded.
AssetManager
  
removeAsset(libraryName:String):void
[static] Remove an asset from the library.
AssetManager
  
saveFLVMetaData(libraryName:String, obj:*):void
[static] Save an FLV's meta data.
AssetManager
  
saveFLVXMPMetaData(libraryName:String, obj:*):void
[static] Save an FLV's XMP meta data.
AssetManager
Property detail
lastLibraryNameproperty
lastLibraryName:String  [read-only]

The last libraryName that was used to register an object.

This is useful for when you don't neccessarily have a libraryName available, but you know that the librayName you need was the last asset registered in the AssetManager.

Implementation
    public static function get lastLibraryName():String

Example
Using the lastLibraryName property.
 
   var am:AssetManager=AssetManager.gi();
   addChild(am.getBitmap(am.lastLibraryName)); //assuming you know the last asset was a bitmap
   

Method detail
addAsset()method
public static function addAsset(libraryName:String, obj:String, source:* = null):void

Register an asset in the library.

Parameters
libraryName:String — The item id.
 
obj:String — The loaded asset object.
 
source:* (default = null)
dispose()method 
public static function dispose():void

Purge all assets from the library. The AssetManager is still usable after a dispose - just the assets are disposed of.

getAsset()method 
public static function getAsset(libraryName:String):*

Get any stored asset.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
*
getBitmap()method 
public static function getBitmap(libraryName:String, smooth:Boolean = true):Bitmap

Get a Bitmap.

This returns a bitmap in the current appliction domain. If preloading is loaded into the same application domain, it will get a bitmap from any swf.

Parameters
libraryName:String — The library name used when the asset was registered.
 
smooth:Boolean (default = true)

Returns
Bitmap
getBitmapFromFZip()method 
public static function getBitmapFromFZip(fzip:FZip, filename:String, receiver:Function, timeout:Number = 100):void

Send a bitmap from an fzip file to a receiver function.

This method needs a reciever callback because the bitmap is loaded by calling "loader.loadBytes" which takes a few milliseconds. The bitmap will not be ready for you if this function returned immediately.

Parameters
fzip:FZip — The FZip object.
 
filename:String — The filename inside the fzip.
 
receiver:Function — The receiver function: function(filename:String,bitmap:Bitmap).
 
timeout:Number (default = 100) — (Optional) The time to wait before triggering the callback in milliseconds.

Example
An example reciever function
 
   function receiveBitmap(filename:String,bitmap:Bitmap):void{}
   

getBitmapFromSWFLibrary()method 
public static function getBitmapFromSWFLibrary(swfLibraryName:String, bitmapLinkageId:String, smooth:Boolean = true):Bitmap

Get a bitmap from a swf library.

Parameters
swfLibraryName:String — The library name used when the swf asset was registered.
 
bitmapLinkageId:String — The bitmaps' linkage id.
 
smooth:Boolean (default = true)

Returns
Bitmap
getClass()method 
public static function getClass(exportName:String):Class

Get a Class.

This returns a class in the current appliction domain. If preloading is loaded into the same application domain, it will get a class from any swf.

Parameters
exportName:String — The item name in the library.

Returns
Class
getClassFromSWFLibrary()method 
public static function getClassFromSWFLibrary(swfLibraryName:String, classNameInLibrary:String):Class

Get a class from a swf library.

Parameters
swfLibraryName:String — The library name used when the swf asset was registered.
 
classNameInLibrary:String — The export class name in the loaded swf's library.

Returns
Class
getFLV()method 
public static function getFLV(libraryName:String):FLV

Get an flv instance.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
FLV
getFLVMetaData()method 
public static function getFLVMetaData(libraryName:String):Object

Get an FLV's meta data.

Parameters
libraryName:String — The library name used when registering the FLV.

Returns
Object
getFLVXMPMetaData()method 
public static function getFLVXMPMetaData(libraryName:String):Object

Get an FLV's XMP meta data.

Parameters
libraryName:String — The library name used when registering the FLV.

Returns
Object
getFont()method 
public static function getFont(exportName:String):Font

Get a font.

This returns a font in the current appliction domain. If preloading is loaded into the same application domain, it will get a font from any swf.

Parameters
exportName:String — The export class name from the library.

Returns
Font
getFontFromSWFLibrary()method 
public static function getFontFromSWFLibrary(swfLibraryName:String, fontLinkageId:String):Font

Get a font from a swf library.

The Font is also registered through Font.registerFont before it's returned.

Parameters
swfLibraryName:String — The library name used when the swf asset was registered.
 
fontLinkageId:String — The font linkage id.

Returns
Font
getFZip()method 
public static function getFZip(libraryName:String):FZip

Get an FZip.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
FZip
getJSON()method 
public static function getJSON(libraryName:String):Object

Returns a JSON object that was loaded with a preloader.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
Object
getMovieClip()method 
public static function getMovieClip(exportName:String):MovieClip

Get a movie clip.

This returns a movie clip in the current appliction domain. If preloading is loaded into the same application domain, it will get a movie clip from any swf.

Parameters
exportName:String — The export class name from the library.

Returns
MovieClip
getMovieClipFromSWFLibrary()method 
public static function getMovieClipFromSWFLibrary(swfLibraryName:String, classNameInLibrary:String):MovieClip

Get a movie clip from a swf library.

Parameters
swfLibraryName:String — The library name used when the swf asset was registered.
 
classNameInLibrary:String — The export class name in the loaded swf's library.

Returns
MovieClip
getNetStream()method 
public static function getNetStream(libraryName:String):NetStream

Get a loaded asset as a NetStream.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
NetStream
getSound()method 
public static function getSound(libraryName:String):Sound

Get a sound.

This returns a sound in the current appliction domain. If preloading is loaded into the same application domain, it will get a sound from any swf.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
Sound
getSoundFromSWFLibrary()method 
public static function getSoundFromSWFLibrary(swfLibraryName:String, soundLinkageId:String):Sound

Get a sound from a swf library

Parameters
swfLibraryName:String — The library name used when the swf asset was registered.
 
soundLinkageId:String — The sounds' linkage id from the swf library.

Returns
Sound
getSprite()method 
public static function getSprite(exportName:String):Sprite

Get a sprite.

This returns a sprite in the current appliction domain. If preloading is loaded into the same application domain, it will get a sprite from any swf.

Parameters
exportName:String — The export class name from the library.

Returns
Sprite
getSpriteFromSWFLibrary()method 
public static function getSpriteFromSWFLibrary(swfLibraryName:String, classNameInLibrary:String):Sprite

Get a sprite from a swf library.

Parameters
swfLibraryName:String — The library name used when the swf asset was registered.
 
classNameInLibrary:String — The export class name in the loaded swf's library.

Returns
Sprite
getStyleSheet()method 
public static function getStyleSheet(libraryName:String):StyleSheet

Get a style sheet that was preloaded from a css file.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
StyleSheet
getSWF()method 
public static function getSWF(libraryName:String):Loader

Get a loaded asset as a SWF.

The asset is cast as a Loader class

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
Loader
getText()method 
public static function getText(libraryName:String):String

Get an asset that was loaded as text.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
String
getXML()method 
public static function getXML(libraryName:String):XML

Get a loaded asset as XML.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
XML
isAvailable()method 
public static function isAvailable(libraryName:String):Boolean

Check to see if an asset is available in the library.

Parameters
libraryName:String — The libraryName used to register the asset.

Returns
Boolean
isNetStreamLoaded()method 
public static function isNetStreamLoaded(libraryName:String):Boolean

Check whether or not a net stream is 100% loaded.

Parameters
libraryName:String — The library name used when the asset was registered.

Returns
Boolean
removeAsset()method 
public static function removeAsset(libraryName:String):void

Remove an asset from the library.

Parameters
libraryName:String — The asset's libraryName to remove.
saveFLVMetaData()method 
public static function saveFLVMetaData(libraryName:String, obj:*):void

Save an FLV's meta data. You should use the same library name that the FLV was loaded with.

Parameters
libraryName:String — The library name used when the FLV was registered.
 
obj:*
saveFLVXMPMetaData()method 
public static function saveFLVXMPMetaData(libraryName:String, obj:*):void

Save an FLV's XMP meta data. You should use the same library name that the FLV was loaded with.

Parameters
libraryName:String — The library name used when the FLV was registered.
 
obj:*