LibraryManager
| Kind of class: | public class |
|---|---|
| Package: | org.casalib.util |
| Inherits from: | none |
| Version: | 12/04/09 |
| Author: | Aaron Clinger |
| Classpath: | org.casalib.util.LibraryManager |
| File last modified: | Sunday, 28 March 2010, 11:55:55 |
Creates an easy way to store multiple libraries in groups and perform centralized retrieval of assets.
Example:
-
package { import flash.display.DisplayObject; import org.casalib.display.CasaMovieClip; import org.casalib.events.LoadEvent; import org.casalib.load.GroupLoad; import org.casalib.load.SwfLoad; import org.casalib.util.LibraryManager; public class MyExample extends CasaMovieClip { protected var _redLibLoad:SwfLoad; protected var _greenLibLoad:SwfLoad; protected var _groupLoad:GroupLoad; public function MyExample() { super(); this._redLibLoad = new SwfLoad("redExternalLib.swf"); this._greenLibLoad = new SwfLoad("greenExternalLib.swf"); LibraryManager.addSwfLoad(this._redLibLoad); LibraryManager.addSwfLoad(this._greenLibLoad); this._groupLoad = new GroupLoad(); this._groupLoad.addLoad(this._redLibLoad); this._groupLoad.addLoad(this._greenLibLoad); this._groupLoad.addEventListener(LoadEvent.COMPLETE, this._onComplete); this._groupLoad.start(); } protected function _onComplete(e:LoadEvent):void { var red:DisplayObject = LibraryManager.createClassByName("RedBox"); var green:DisplayObject = LibraryManager.createClassByName("GreenBox"); green.x = 100; this.addChild(red); this.addChild(green); } } }
Summary
Constants
- GROUP_DEFAULT : String
Class methods
- addSwfLoad (swfLoad:SwfLoad, groupId:String = LibraryManager) : void
- Adds a SwfLoad to LibraryManager.
- removeSwfLoad (swfLoad:SwfLoad, groupId:String = LibraryManager) : void
- Removes a SwfLoad from LibraryManager.
- hasSwfLoad (swfLoad:SwfLoad, groupId:String = LibraryManager) : Boolean
- Determines if a LibraryManager group contains a specific SwfLoad.
- removeGroup (groupId:String) : void
- Removes all SwfLoads from a group.
- getGroupIdBySwfLoad (swfLoad:SwfLoad) : String
- Determines which LibraryManager group contains a specific SwfLoad.
- getGroupIdByDefinition (name:String) : String
- Determines which LibraryManager group contains a specific definition.
- getDefinition (name:String, groupId:String = LibraryManager) : Object
- Gets a public definition from a library group.
- hasDefinition (name:String, groupId:String = LibraryManager) : Boolean
- Checks to see if a public definition exists within the library group.
- getClassByName (className:String, groupId:String = LibraryManager) : Class
- Retrieves a class from a library group.
- createClassByName (className:String, arguments:Array = null, groupId:String = LibraryManager) : *
- Instatiates a class from a library group.
Constants
GROUP_DEFAULT
public static const GROUP_DEFAULT:String = 'groupDefault'
(read)
Class methods
addSwfLoad
Adds a SwfLoad to LibraryManager.
Parameters:
swfLoad:
The SwfLoad you wish to add.
groupId:
The identifier of the group you wish to add the SwfLoad to.
createClassByName
public static function createClassByName (
className:String,
arguments:Array = null,
groupId:String = LibraryManager) : *
Instatiates a class from a library group.
Parameters:
className:
The full name of the class you wish to instantiate from the loaded SWF.
arguments:
The optional parameters to be passed to the class constructor.
groupId :
The identifier of the group you wish to instantiate the class from.
Returns:
- A reference to the newly instantiated class or
nullif theclassNamedoesn't exist.
getClassByName
public static function getClassByName (
className:String,
groupId:String = LibraryManager) : Class
Retrieves a class from a library group.
Parameters:
className:
The full name of the class you wish to receive from the loaded SWF.
groupId :
The identifier of the group you wish to retrieve the class from.
Returns:
- A Class reference or
nullif theclassNamedoesn't exist.
getDefinition
public static function getDefinition (
name:String,
groupId:String = LibraryManager) : Object
Gets a public definition from a library group.
Parameters:
name :
The name of the definition.
groupId:
The identifier of the group you wish to retrieve the definition from.
Returns:
- The object associated with the definition or
nullif thenamedoesn't exist.
getGroupIdByDefinition
public static function getGroupIdByDefinition (
name:String) : String
Determines which LibraryManager group contains a specific definition.
Parameters:
name:
The name of the definition to determine which group it belongs to.
Returns:
- The id for the containing group or
nullif the definition is not part of a group.
Usage note:
- A definition could belong to more than one group.
getGroupIdBySwfLoad
Determines which LibraryManager group contains a specific SwfLoad.
Parameters:
swfLoad:
The SwfLoad to determine which group it belongs to.
Returns:
- The id for the containing group or
nullif the SwfLoad is not part of a group.
Usage note:
- A SwfLoad could belong to more than one group.
hasDefinition
public static function hasDefinition (
name:String,
groupId:String = LibraryManager) : Boolean
Checks to see if a public definition exists within the library group.
Parameters:
name :
The name of the definition.
groupId:
The identifier of the group in which to search for the definition.
Returns:
- Returns
trueif the specified definition exists; otherwisefalse.
hasSwfLoad
Determines if a LibraryManager group contains a specific SwfLoad.
Parameters:
swfLoad:
The SwfLoad you wish to search for.
groupId:
The identifier of the group you wish to search for the SwfLoad in.
Returns:
- Returns
trueif the specified SwfLoad is contained in the LibraryManager group; otherwisefalse.
removeGroup
public static function removeGroup (
groupId:String) : void
Removes all SwfLoads from a group.
Parameters:
groupId:
The identifier of the group you wish to empty.
removeSwfLoad
Removes a SwfLoad from LibraryManager.
Parameters:
swfLoad:
The SwfLoad you wish to remove.
groupId:
The identifier of the group you wish to remove the SwfLoad from.