DisplayListWatcher

public class
feathers.core.DisplayListWatcher

Description

Watches a container on the display list. As new display objects are added, and if they match a specific type, they will be passed to initializer functions to set properties, call methods, or otherwise modify them. Useful for initializing skins and styles on UI controls.

In the example below, the buttonInitializer() function will be called when a Button is added to the display list:

setInitializerForClass(Button, buttonInitializer);

However, initializers are not called for subclasses. If a Check is added to the display list (Check extends Button), the buttonInitializer() function will not be called. This important restriction allows subclasses to have different skins, for instance.

You can target a specific subclass with the same initializer function without adding it for all subclasses:

setInitializerForClass(Button, buttonInitializer);
setInitializerForClass(Check, buttonInitializer);

In this case, Button and Check will trigger the buttonInitializer() function, but Radio (another subclass of Button) will not.

You can target a class and all of its subclasses, using a different function. This is recommended only when you are absolutely sure that no subclasses will need a separate initializer.

setInitializerForClassAndSubclasses(Button, buttonInitializer);

In this case, Button, Check, Radio and every other subclass of Button (including any subclasses that you create yourself) will trigger the buttonInitializer() function.

API overview

Constructor

DisplayListWatcher ( topLevelContainer: DisplayObjectContainer )
Constructor

Attributes

Public attributes

initializeOnce: Boolean

Determines if objects added to the display list are initialized only once or every time that they are re-added

processRecursively: Boolean

Determines if only the object added should be processed or if its children should be processed recursively

requiredBaseClass: Type

The minimum base class required before the AddedWatcher will check to see if a particular display object has any initializers

Protected attributes

Functions

Public functions

clearInitializerForClass ( type: Type , withName: String = null ): Void

If an initializer exists for a specific class, it will be removed completely

clearInitializerForClassAndSubclasses ( type: Type ): Void

If an initializer exists for a specific class and its subclasses, the initializer will be removed completely

dispose (): Void

Stops listening to the root and cleans up anything else that needs to be disposed

exclude ( target: DisplayObject ): Void

Excludes a display object, and all if its children (if any) from being watched

getInitializerForClass ( type: Type , withName: String = null ): Function

If an initializer exists for a specific class, it will be returned

getInitializerForClassAndSubclasses ( type: Type ): Function

If an initializer exists for a specific class and its subclasses, the initializer will be returned

isExcluded ( target: DisplayObject ): Boolean

Determines if an object is excluded from being watched

setInitializerForClass ( type: Type , initializer: Function , withName: String = null ): Void

Sets the initializer for a specific class

setInitializerForClassAndSubclasses ( type: Type , initializer: Function ): Void

Sets an initializer for a specific class and any subclasses

Constructor

DisplayListWatcher ( topLevelContainer: DisplayObjectContainer )

Constructor. @param topLevelContainer The root display object to watch (not necessarily Starling's root object)

Attributes

initializeOnce: Boolean

Determines if objects added to the display list are initialized only once or every time that they are re-added.

processRecursively: Boolean

Determines if only the object added should be processed or if its children should be processed recursively.

requiredBaseClass: Type

The minimum base class required before the AddedWatcher will check to see if a particular display object has any initializers.

Protected attributes

Functions

clearInitializerForClass ( type: Type , withName: String = null ): Void

If an initializer exists for a specific class, it will be removed completely.

Parameters

type: Type
withName: String = null


clearInitializerForClassAndSubclasses ( type: Type ): Void

If an initializer exists for a specific class and its subclasses, the initializer will be removed completely.

Parameters

type: Type


dispose (): Void

Stops listening to the root and cleans up anything else that needs to be disposed. If a DisplayListWatcher is extended for a theme, it should also dispose textures and other assets.



exclude ( target: DisplayObject ): Void

Excludes a display object, and all if its children (if any) from being watched.

Parameters

target: DisplayObject


getFullTypeName (): String
Inherited from Object

native

Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.


Returns

String fully qualified type name of the Object.

getInitializerForClass ( type: Type , withName: String = null ): Function

If an initializer exists for a specific class, it will be returned.

Parameters

type: Type
withName: String = null


getInitializerForClassAndSubclasses ( type: Type ): Function

If an initializer exists for a specific class and its subclasses, the initializer will be returned.

Parameters

type: Type


getType (): Type
Inherited from Object

native

Gets the Type that describes the Object.


Returns

Type The Type that describes the object.

getTypeName (): String
Inherited from Object

native

Gets the type name of the Object.


Returns

String type name of the Object.

isExcluded ( target: DisplayObject ): Boolean

Determines if an object is excluded from being watched.

Parameters

target: DisplayObject


setInitializerForClass ( type: Type , initializer: Function , withName: String = null ): Void

Sets the initializer for a specific class.

Parameters

type: Type
initializer: Function
withName: String = null


setInitializerForClassAndSubclasses ( type: Type , initializer: Function ): Void

Sets an initializer for a specific class and any subclasses. This option can potentially hurt performance, so use sparingly.

Parameters

type: Type
initializer: Function


toString (): String
Inherited from Object

native

Returns a String that describes the Object. This can be overriden to provide extra details when printing objects using trace().


Returns

String String that described the Object.

: