Packagecom.bourre.core
Classpublic class AbstractLocator
ImplementsLocator, TypedContainer
SubclassesChannelListenerExpert, ConstructorExpert, FrontController, GraphicLoaderLocator, MethodExpert, ModelLocator, PluginExpert, PropertyExpert, ResourceExpert, ServiceLocator, SoundLoaderLocator, SoundMixerLocator, TypedFactoryLocator, VideoDisplayLocator, ViewLocator

Player version: Flash Player 9.0
Language version: ActionScript 3.0

The AbstractLocator class gives an abstract implementation for Locator objects.



Protected Properties
 PropertyDefined by
  _m : HashMap
Map storing String keys associated with Object values.
AbstractLocator
Public Methods
 MethodDefined by
  
AbstractLocator(type:Class = null, typeListener:Class = null, logger:Log = null)
Creates a new locator instance.
AbstractLocator
  
add(d:Dictionary):void
Adds all ressources contained in the passed-in dictionnary into this locator instance.
AbstractLocator
  
addEventListener(type:String, listener:Object, ... rest):Boolean
Adds an event listener for the specified event type.
AbstractLocator
  
callMethodOnAllValues(methodName:String, ... args):void
Takes all values of a Locator and call on each value the method name passed as 1st argument.
AbstractLocator
  
getKeys():Array
Returns an Array view of the keys contained in this locator.
AbstractLocator
  
Returns the exclusive logger object owned by this locator.
AbstractLocator
  
getType():Class
Return the class type of elements in this container.
AbstractLocator
  
getValues():Array
Returns an Array view of the values contained in this locator.
AbstractLocator
  
isRegistered(name:String):Boolean
Returns true is there is a ressource associated with the passed-in key.
AbstractLocator
  
isTyped():Boolean
Returns true if this container perform a verification of the type of elements.
AbstractLocator
  
locate(name:String):Object
Returns the ressource associated with the passed-in key.
AbstractLocator
  
matchType(o:*):Boolean
Verify that the passed-in object type match the current container element's type.
AbstractLocator
  
processOnAllValues(f:Function, ... args):void
Takes all values of a Locator and pass them one by one as arguments to a method of an object.
AbstractLocator
  
register(name:String, o:Object):Boolean
Registers passed-in object with identifier name to this locator.
AbstractLocator
  
release():void
Clears all association between keys and objects registered for this locator.
AbstractLocator
  
removeEventListener(type:String, listener:Object):Boolean
Removes the passed-in listener for listening the specified event.
AbstractLocator
  
toString():String
Returns the string representation of this instance.
AbstractLocator
  
unregister(name:String):Boolean
Unregisters object registered with identifier name.
AbstractLocator
Protected Methods
 MethodDefined by
  
Broadcast the passed-in event object to listeners according to the event's type.
AbstractLocator
  
Returns event Broadcaster owned by this locator.
AbstractLocator
  
onRegister(name:String = null, o:Object = null):void
Call this method to do something when an object is registered in locator.
AbstractLocator
  
onUnregister(name:String = null):void
Call this method to do something when an object is unregistered from locator.
AbstractLocator
Property detail
_mproperty
protected var _m:HashMap

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Map storing String keys associated with Object values.

Constructor detail
AbstractLocator()constructor
public function AbstractLocator(type:Class = null, typeListener:Class = null, logger:Log = null)

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Creates a new locator instance. If the type argument is defined, the locator is considered as typed, and then the type of all elements inserted in this locator is checked.

Parameters
type:Class (default = null)Class type for locator elements.
 
typeListener:Class (default = null)Class type for locator listeners.
 
logger:Log (default = null) — custom logger to output locator messages.
Method detail
add()method
public function add(d:Dictionary):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Adds all ressources contained in the passed-in dictionnary into this locator instance. If there is keys used both in the locator and in the dictionnary an exception is thrown.

Parameters
d:Dictionary — dictionnary instance which contains ressources to be added

Throws
IllegalArgumentException — One or more keys present in the dictionnary already exist in this locator instance.
addEventListener()method 
public function addEventListener(type:String, listener:Object, ... rest):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Adds an event listener for the specified event type. There is two behaviors for the addEventListener function :

  1. The passed-in listener is an object : The object is added as listener only for the specified event, the object must have a function with the same name than type or at least a handleEvent function.
  2. The passed-in listener is a function : A Delegate object is created and then added as listener for the event type. There is no restriction on the name of the function. If the rest is not empty, all elements in it is used as additional arguments into the delegate object.

Parameters
type:String — name of the event for which register the listener
 
listener:Object — object or function which will receive this event
 
... rest — additional arguments for the function listener

Returns
Booleantrue if the function have been succesfully added as listener fot the passed-in event

Throws
UnsupportedOperationException — If the listener is an object which have neither a function with the same name than the event type nor a function called handleEvent
broadcastEvent()method 
protected function broadcastEvent(e:Event):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Broadcast the passed-in event object to listeners according to the event's type. The event is broadcasted to both listeners registered specifically for this event type and global listeners in the broadcaster.

If the target property of the passed-in event is null, it will be set using the value of the source property of this event broadcaster.

Parameters
e:Event — event object to broadcast
callMethodOnAllValues()method 
public function callMethodOnAllValues(methodName:String, ... args):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Takes all values of a Locator and call on each value the method name passed as 1st argument.

Basical example which plays all MovieClips from frame 10.

Parameters
methodName:String — method name to call on each value stored in the locator.
 
... args — args additionnal parameters.

Example
                  myMovieClipLocator.callMethodOnAllValues( "gotoAndPlay", 10 );
         

getBroadcaster()method 
protected function getBroadcaster():Broadcaster

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns event Broadcaster owned by this locator.

Returns
Broadcaster — The event Broadcaster owned by this locator.
getKeys()method 
public function getKeys():Array

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns an Array view of the keys contained in this locator.

Returns
Array — an array view of the keys contained in this locator
getLogger()method 
public function getLogger():Log

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the exclusive logger object owned by this locator. It allow this logger to send logging message directly on its owner logging channel.

Returns
Log — logger associated to the owner
getType()method 
public function getType():Class

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Return the class type of elements in this container.

An untyped container returns null, as the wildcard type (/code>) is not a Class and Object class doesn't fit for primitive types.

Returns
ClassClass type of the container's elements
getValues()method 
public function getValues():Array

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns an Array view of the values contained in this locator.

Returns
Array — an array view of the values contained in this locator
isRegistered()method 
public function isRegistered(name:String):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true is there is a ressource associated with the passed-in key. To avoid errors when retreiving ressources from a locator you should systematically use the isRegistered function to check if the ressource you would access is already accessible before any call to the locate function.

Parameters
name:String

Returns
Booleantrue is there is a ressource associated with the passed-in key.
isTyped()method 
public function isTyped():Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if this container perform a verification of the type of elements.

Returns
Booleantrue if this container perform a verification of the type of elements.
locate()method 
public function locate(name:String):Object

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the ressource associated with the passed-in key. If there is no ressource identified by the passed-in key, the function will fail with an error. To avoid the throw of an exception when attempting to access to a ressource, take care to check the existence of the ressource before trying to access to it.

Parameters
name:String — identifier of the ressource to access

Returns
Object — the ressource associated with the passed-in key

Throws
NoSuchElementException — There is no ressource associated with the passed-in key
matchType()method 
public function matchType(o:*):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Verify that the passed-in object type match the current container element's type.

Parameters
o:*

Returns
Booleantrue if the object is elligible for this container, either false.
onRegister()method 
protected function onRegister(name:String = null, o:Object = null):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Call this method to do something when an object is registered in locator.

Parameters
name:String (default = null) — Name of the registered object
 
o:Object (default = null) — The registered object
onUnregister()method 
protected function onUnregister(name:String = null):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Call this method to do something when an object is unregistered from locator.

Parameters
name:String (default = null) — Name of the registered object
processOnAllValues()method 
public function processOnAllValues(f:Function, ... args):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Takes all values of a Locator and pass them one by one as arguments to a method of an object. It's exactly the same concept as batch processing in audio or video software, when you choose to run the same actions on a group of files.

Basical example which sets _alpha value to .4 and scale to 50 on all MovieClips nested in the Locator instance:

Parameters
f:Function — function to execute on each value stored in the locator.
 
... args — args additionnal parameters.

Example
         
         function changeAlpha( mc : MovieClip, a : Number, s : Number )
         {
              mc._alpha = a;
              mc._xscale = mc._yscale = s;
         }
                  myMovieClipLocator.processOnAllValues( changeAlpha, .4, 50 );
         

register()method 
public function register(name:String, o:Object):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Registers passed-in object with identifier name to this locator.

Parameters
name:String — Key identifier
 
o:Object — Object to store

Returns
Booleantrue if success

Throws
IllegalArgumentException — Key or object are already defined in this locator.
release()method 
public function release():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Clears all association between keys and objects registered for this locator.

removeEventListener()method 
public function removeEventListener(type:String, listener:Object):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes the passed-in listener for listening the specified event. The listener could be either an object or a function.

Parameters
type:String — name of the event for which unregister the listener
 
listener:Object — object or function to be unregistered

Returns
Booleantrue if the listener have been successfully removed as listener for the passed-in event
toString()method 
public function toString():String

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the string representation of this instance.

Returns
String — the string representation of this instance
unregister()method 
public function unregister(name:String):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Unregisters object registered with identifier name.

Parameters
name:String — Key identifier

Returns
Booleantrue if success