mx.styles

# AdvancedStyleClient - AS3 Flex

Package | mx.styles
Class | public class AdvancedStyleClient
Inheritance | AdvancedStyleClient EventDispatcher Object
Implements | IAdvancedStyleClient, IFlexModule, IMXMLObject
Subclasses | GlobalizationBase, Sort, SortField

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

A base class that can be used when implementing an object that uses the `IAdvancedStyleClient` interface. The base class supplies implementations of the methods and properties required for an object to participate in the style subsystem.

In addition to the `IAdvancedStyleClient` interface, this object also implements the `IFlexModule` and `IMXMLObject` interfaces. The `IMXMLObject` interface contains an `initialized` method that is called when the class is instantiated using an MXML declaration. The implementation of the `initialized` method provided by this base class will add the class instance to the document object that contains the MXML declaration. For more details, see the description of the `initilized` method.

Related API Elements

mx.styles.IAdvancedStyleClient
initialized

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | className : String [read-only] The name of the component class. | AdvancedStyleClient
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | id : String The identity of the component. | AdvancedStyleClient
|  | inheritingStyles : Object An object containing the inheritable styles for this non-visual style client instance. | AdvancedStyleClient
|  | moduleFactory : IFlexModuleFactory A module factory is used as context for finding the style manager that controls the styles for this non-visual style client instance. | AdvancedStyleClient
|  | nonInheritingStyles : Object The beginning of this component's chain of non-inheriting styles. | AdvancedStyleClient
|  | styleDeclaration : CSSStyleDeclaration The style declaration that holds the inline styles declared by this object. | AdvancedStyleClient
|  | styleManager : IStyleManager2 [read-only] Returns the StyleManager instance used by this component. | AdvancedStyleClient
|  | styleName : Object The source of this object's style values. | AdvancedStyleClient
|  | styleParent : IAdvancedStyleClient A component's parent is used to evaluate descendant selectors. | AdvancedStyleClient

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | AdvancedStyleClient() Constructor. | AdvancedStyleClient
|  | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. | EventDispatcher
|  | clearStyle(styleProp:String):void Deletes a style property from this component instance. | AdvancedStyleClient
|  | dispatchEvent(event:Event):Boolean Dispatches an event into the event flow. | EventDispatcher
|  | getClassStyleDeclarations():Array Returns an Array of CSSStyleDeclaration objects for the type selector that applies to this component, or null if none exist. | AdvancedStyleClient
|  | getStyle(styleProp:String):* Gets a style property that has been set anywhere in this component's style lookup chain. | AdvancedStyleClient
|  | hasCSSState():Boolean Returns true if currentCSSState is not null. | AdvancedStyleClient
|  | hasEventListener(type:String):Boolean Checks whether the EventDispatcher object has any listeners registered for a specific type of event. | EventDispatcher
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | initialized(document:Object, id:String):void The initialized method is called when this class or a class that extends this class is used in an MXML declaration. | AdvancedStyleClient
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | matchesCSSState(cssState:String):Boolean Returns true if cssState matches currentCSSState. | AdvancedStyleClient
|  | matchesCSSType(cssType:String):Boolean Determines whether this instance is the same as, or is a subclass of, the given type. | AdvancedStyleClient
|  | notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void Propagates style changes to the children of this style client instance. | AdvancedStyleClient
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | regenerateStyleCache(recursive:Boolean):void Sets up the internal style cache values so that the getStyle() method functions. | AdvancedStyleClient
|  | registerEffects(effects:Array):void Registers the EffectManager as one of the event listeners for each effect event. | AdvancedStyleClient
|  | removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void Removes a listener from the EventDispatcher object. | EventDispatcher
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | setStyle(styleProp:String, newValue:*):void Sets a style property on this component instance. | AdvancedStyleClient
|  | styleChanged(styleProp:String):void Detects changes to style properties. | AdvancedStyleClient
|  | stylesInitialized():void Flex calls the stylesInitialized() method when the styles for a component are first initialized. | AdvancedStyleClient
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object
|  | willTrigger(type:String):Boolean Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. | EventDispatcher

Events
Click for more information on events
Hide Inherited Events
Show Inherited Events

| Event | Summary | Defined By
--- | --- | --- | ---
|  | activate | [broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active. | EventDispatcher
|  | deactivate | [broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive. | EventDispatcher

Property Detail

### className

property

`className:String` [read-only]

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10.1, AIR 2.5

The name of the component class.

Implementation
`public function get className():String`

### id

property

`id:String`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

The identity of the component.

Implementation
`public function get id():String`
`public function set id(value:String):void`

### inheritingStyles

property

`inheritingStyles:Object`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

An object containing the inheritable styles for this non-visual style client instance.

Implementation
`public function get inheritingStyles():Object`
`public function set inheritingStyles(value:Object):void`

### moduleFactory

property

`moduleFactory:IFlexModuleFactory`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

A module factory is used as context for finding the style manager that controls the styles for this non-visual style client instance.

Implementation
`public function get moduleFactory():IFlexModuleFactory`
`public function set moduleFactory(value:IFlexModuleFactory):void`

### nonInheritingStyles

property

`nonInheritingStyles:Object`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

The beginning of this component's chain of non-inheriting styles. The `getStyle()` method simply accesses `nonInheritingStyles[styleName]` to search the entire prototype-linked chain. This object is set up by `initProtoChain()`. Developers typically never need to access this property directly.

Implementation
`public function get nonInheritingStyles():Object`
`public function set nonInheritingStyles(value:Object):void`

### styleDeclaration

property

`styleDeclaration:CSSStyleDeclaration`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

The style declaration that holds the inline styles declared by this object.

Implementation
`public function get styleDeclaration():CSSStyleDeclaration`
`public function set styleDeclaration(value:CSSStyleDeclaration):void`

Related API Elements

mx.styles.CSSStyleDeclaration

### styleManager

property

`styleManager:IStyleManager2` [read-only]

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Returns the StyleManager instance used by this component.

Implementation
`public function get styleManager():IStyleManager2`

### styleName

property

`styleName:Object`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

The source of this object's style values. The value of the `styleName` property can be one of three possible types:

- String, such as "headerStyle". The String names a class selector that is defined in a CSS style sheet.
- CSSStyleDeclaration, such as `StyleManager.getStyleDeclaration(".headerStyle")`.
- UIComponent. The object that implements this interface inherits all the style values from the referenced UIComponent.

Implementation
`public function get styleName():Object`
`public function set styleName(value:Object):void`

### styleParent

property

`styleParent:IAdvancedStyleClient`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

A component's parent is used to evaluate descendant selectors. A parent must also be an IAdvancedStyleClient to participate in advanced style declarations.

Implementation
`public function get styleParent():IAdvancedStyleClient`
`public function set styleParent(value:IAdvancedStyleClient):void`
Constructor Detail

### AdvancedStyleClient

()
Constructor

`public function AdvancedStyleClient()`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Constructor.

Method Detail

### clearStyle

()
method

`public function clearStyle(styleProp:String):void`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Deletes a style property from this component instance.

This does not necessarily cause the `getStyle()` method to return `undefined`.

Parameters

| `styleProp:String` — Name of the style property.

### getClassStyleDeclarations

()
method

`public function getClassStyleDeclarations():Array`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Returns an Array of CSSStyleDeclaration objects for the type selector that applies to this component, or `null` if none exist.

For example, suppose that component MyButton extends Button. This method first looks for a MyButton selector; then, it looks for a Button type selector; finally, it looks for a UIComponent type selector.

Returns

| `Array` — Array of CSSStyleDeclaration objects.

### getStyle

()
method

`public function getStyle(styleProp:String):*`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Gets a style property that has been set anywhere in this component's style lookup chain.

This same method is used to get any kind of style property, so the value returned may be a Boolean, String, Number, int, uint (for an RGB color), Class (for a skin), or any kind of object. Therefore the return type is specified as *.

If you are getting a particular style property, you will know its type and will often want to store the result in a variable of that type. You can use either the `as` operator or coercion to do this. For example:

          var backgroundColor:uint = getStyle("backgroundColor") as int;

          or

          var backgroundColor:uint = int(getStyle("backgroundColor"));

If the style property has not been set anywhere in the style lookup chain, the value returned by the `getStyle()` method is `undefined`. Note that `undefined` is a special value that is not the same as `false`, the empty String (`""`), `NaN`, 0, or `null`. No valid style value is ever `undefined`. You can use the static method `StyleManager.isValidStyleValue()` to test whether the value was set.

Parameters

| `styleProp:String` — Name of the style property.

Returns

| `*` — Style value.

### hasCSSState

()
method

`public function hasCSSState():Boolean`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.6

Runtime Versions: | Flash Player 10, AIR 2.5

Returns `true` if `currentCSSState` is not `null`. Typically, you do not call this method directly. It is called by the `mx.styles.CSSCondition.matchesStyleClient()` method.

Note Spark components use their skin state as the pseudo state. Halo components use the `currentState` property.

Returns

| `Boolean` — `true` if `currentCSSState` is not `null`. By default, `currentCSSState` is the same as `currentState`. If no state exists, return false.

### initialized

()
method

`public function initialized(document:Object, id:String):void`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

The initialized method is called when this class or a class that extends this class is used in an MXML declaration. It is called after the implementing object has been created and all component properties specified on the MXML tag have been initialized.

If the document that created this object is a `UIComponent`, (e.g. Application, Module, etc.) then the UIComponent's `addStyleClient` method will be called to add this object to the UIComponent's list of non-visual style clients. This allows the object to inherit styles from the document.

Parameters

| `document:Object` — The MXML document that created this object.
| `id:String` — The identifier used by the document object to refer to this object.

### matchesCSSState

()
method

`public function matchesCSSState(cssState:String):Boolean`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Returns `true` if `cssState` matches `currentCSSState`. Typically, you do not call this method directly. It is called by the `mx.styles.CSSCondition.matchesStyleClient()` method.

Note Spark components use their skin state as the pseudo state. Halo components use the `currentState` property.

Parameters

| `cssState:String` — A possible value of `CSSCondition.value`. It represents the current state of this component used to match CSS pseudo-selectors.

Returns

| `Boolean` — `true` if `cssState` matches `currentCSSState`. By default, `currentCSSState` is the same as `currentState`. If no state exists, return null.

### matchesCSSType

()
method

`public function matchesCSSType(cssType:String):Boolean`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Determines whether this instance is the same as, or is a subclass of, the given type. Typically, you do not call this method directly. It is called by the `mx.styles.CSSCondition.matchesStyleClient()` method.

Parameters

| `cssType:String` — A CSSSelector object.

Returns

| `Boolean` — `true` if `cssType` is in the hierarchy of qualified type selectors.

### notifyStyleChangeInChildren

()
method

`public function notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Propagates style changes to the children of this style client instance. A non-visual style client (i.e. a style client that is not a DisplayObject) does not have children, therefore this method does not do anything for non-visual style clients.

Parameters

| `styleProp:String` — Name of the style property.
| `recursive:Boolean` — Whether to propagate the style changes to the children's children.

### regenerateStyleCache

()
method

`public function regenerateStyleCache(recursive:Boolean):void`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Sets up the internal style cache values so that the `getStyle()` method functions.

Parameters

| `recursive:Boolean` — Regenerate the proto chains of the children.

### registerEffects

()
method

`public function registerEffects(effects:Array):void`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Registers the EffectManager as one of the event listeners for each effect event.

Parameters

| `effects:Array` — An Array of Strings of effect names.

### setStyle

()
method

`public function setStyle(styleProp:String, newValue:*):void`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Sets a style property on this component instance.

This may override a style that was set globally.

Calling the `setStyle()` method can result in decreased performance. Use it only when necessary.

Parameters

| `styleProp:String` — Name of the style property.
| `newValue:*` — New value for the style.

### styleChanged

()
method

`public function styleChanged(styleProp:String):void`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Detects changes to style properties. When any style property is set, Flex calls the `styleChanged()` method, passing to it the name of the style being set.

This is an advanced method that you might override when creating a subclass of `AdvancedStyleClient`. When you create a custom class, you can override the `styleChanged()` method to check the style name passed to it, and handle the change accordingly. This lets you override the default behavior of an existing style, or add your own custom style properties.

Parameters

| `styleProp:String` — The name of the style property, or null if all styles for this style client have changed.

### stylesInitialized

()
method

`public function stylesInitialized():void`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | Flash Player 10, AIR 2.5

Flex calls the `stylesInitialized()` method when the styles for a component are first initialized.

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00