LibraryManager

Kind of class:public class
Package:org.casalib.util
Inherits from:none
Version:02/10/09
Author:Aaron Clinger
Classpath:org.casalib.util.LibraryManager
File last modified:Tuesday, 10 February 2009, 18:13:07
Creates an easy way to store multiple LibraryLoads in groups and perform centralized retrieval of assets.
Example:
  • package {
        import flash.display.MovieClip;
        import flash.display.DisplayObject;
        import org.casalib.load.LibraryLoad;
        import org.casalib.load.GroupLoad;
        import org.casalib.events.LoadEvent;
        import org.casalib.util.LibraryManager;
    
    
        public class MyExample extends MovieClip {
            protected var _redLibLoad:LibraryLoad;
            protected var _greenLibLoad:LibraryLoad;
            protected var _groupLoad:GroupLoad;
    
    
            public function MyExample() {
                super();
    
                this._redLibLoad   = new LibraryLoad("redExternalLib.swf");
                this._greenLibLoad = new LibraryLoad("greenExternalLib.swf");
    
                LibraryManager.addLibraryLoad(this._redLibLoad);
                LibraryManager.addLibraryLoad(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
Class methods
  • addLibraryLoad (libLoad:LibraryLoad, groupId:String = LibraryManager.GROUP_DEFAULT) : void
    • Adds a LibraryLoad to LibraryManager.
  • removeLibraryLoad (libLoad:LibraryLoad, groupId:String = LibraryManager.GROUP_DEFAULT) : void
    • Removes a LibraryLoad from LibraryManager.
  • removeGroup (groupId:String) : void
    • Removes all LibraryLoads from a group.
  • getDefinition (name:String, groupId:String = LibraryManager.GROUP_DEFAULT) : Object
    • Gets a public definition from a library group.
  • hasDefinition (name:String, groupId:String = LibraryManager.GROUP_DEFAULT) : Boolean
    • Checks to see if a public definition exists within the library group.
  • getClassByName (className:String, groupId:String = LibraryManager.GROUP_DEFAULT) : Class
    • Retrieves a class from a library group.
  • createClassByName (className:String, arguments:Array = null, groupId:String = LibraryManager.GROUP_DEFAULT) : *
    • Instatiates a class from a library group.

Constants

GROUP_DEFAULT

public static const GROUP_DEFAULT:String = 'groupDefault'
(read)

Class methods

addLibraryLoad

public static function addLibraryLoad (
libLoad:LibraryLoad, groupId:String = LibraryManager.GROUP_DEFAULT) : void

Adds a LibraryLoad to LibraryManager.
Parameters:
libLoad:
The LibraryLoad you wish to add.
groupId:
The identifier of the group you wish to add the LibraryLoad to.

createClassByName

public static function createClassByName (
className:String, arguments:Array = null, groupId:String = LibraryManager.GROUP_DEFAULT) : *

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 null if the className doesn't exist.

getClassByName

public static function getClassByName (
className:String, groupId:String = LibraryManager.GROUP_DEFAULT) : 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 null if the className doesn't exist.

getDefinition

public static function getDefinition (
name:String, groupId:String = LibraryManager.GROUP_DEFAULT) : 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 null if the name doesn't exist.

hasDefinition

public static function hasDefinition (
name:String, groupId:String = LibraryManager.GROUP_DEFAULT) : 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 true if the specified definition exists; otherwise false.

removeGroup

public static function removeGroup (
groupId:String) : void

Removes all LibraryLoads from a group.
Parameters:
groupId:
The identifier of the group you wish to empty.

removeLibraryLoad

public static function removeLibraryLoad (
libLoad:LibraryLoad, groupId:String = LibraryManager.GROUP_DEFAULT) : void

Removes a LibraryLoad from LibraryManager.
Parameters:
libLoad:
The LibraryLoad you wish to remove.
groupId:
The identifier of the group you wish to remove the LibraryLoad from.