| 包 | mx.styles |
| 接口 | public interface IStyleClient extends ISimpleStyleClient |
| 实现器 | AdvancedDataGridItemRenderer, DataGridItemRenderer, HaloFocusRect, StyleProxy, UIComponent |
如果对象不需要在本地存储样式值,则该对象可改为实现 ISimpleStyleClient 接口。
另请参见
| 属性 | 定义方 | ||
|---|---|---|---|
| className : String [只读 (read-only)] 组件类的名称。 | IStyleClient | ||
| inheritingStyles : Object 包含此组件的可继承样式的对象。 | IStyleClient | ||
| nonInheritingStyles : Object 包含此组件的不可继承样式的对象。 | IStyleClient | ||
| styleDeclaration : CSSStyleDeclaration 该对象使用的样式声明。 | IStyleClient | ||
![]() | styleName : Object 该对象的样式值的源。 | ISimpleStyleClient | |
| 方法 | 定义方 | ||
|---|---|---|---|
删除此组件实例中的样式属性。 | IStyleClient | ||
为应用于该组件的类型选择器返回 CSSStyleDeclaration 对象数组,如果不存在则返回 null。 | IStyleClient | ||
获取已在此组件的样式查找链中的某个位置设置过的样式属性。 | IStyleClient | ||
向该组件的子项传送样式更改。 | IStyleClient | ||
设置内部样式缓存值,以便 getStyle() 方法可以起作用。 | IStyleClient | ||
将 EffectManager 注册为每个效果事件的事件侦听器之一。 | IStyleClient | ||
对此组件实例设置样式属性。 | IStyleClient | ||
![]() | 当样式属性的值发生更改时调用。 | ISimpleStyleClient | |
| className | 属性 |
| inheritingStyles | 属性 |
inheritingStyles:Object [读写] 包含此组件的可继承样式的对象。
public function get inheritingStyles():Object public function set inheritingStyles(value:Object):void| nonInheritingStyles | 属性 |
nonInheritingStyles:Object [读写] 包含此组件的不可继承样式的对象。
public function get nonInheritingStyles():Object public function set nonInheritingStyles(value:Object):void| styleDeclaration | 属性 |
styleDeclaration:CSSStyleDeclaration [读写] 该对象使用的样式声明。
public function get styleDeclaration():CSSStyleDeclaration public function set styleDeclaration(value:CSSStyleDeclaration):void另请参见
| clearStyle | () | 方法 |
public function clearStyle(styleProp:String):void删除此组件实例中的样式属性。
此操作不一定会使 getStyle() 方法返回 undefined。
参数
styleProp:String — 样式属性的名称。 |
| getClassStyleDeclarations | () | 方法 |
public function getClassStyleDeclarations():Array
为应用于该组件的类型选择器返回 CSSStyleDeclaration 对象数组,如果不存在则返回 null。
例如,假定组件 MyButton 扩展了 Button。该方法首先查找 MyButton 选择器;然后查找 Button 类型选择器;最后查找 UIComponent 类型选择器。
返回Array — CSSStyleDeclaration 对象数组。 |
| getStyle | () | 方法 |
public function getStyle(styleProp:String):*获取已在此组件的样式查找链中的某个位置设置过的样式属性。
因为此方法同样可用于获取任何类型的样式属性,所以返回值可能是 Boolean、String、Number、int、uint(用于 RGB 颜色)、Class(用于外观)或任何类型的对象。因此,返回类型被指定为 *。
如果要获取特定的样式属性,您需要了解其类型,而且通常希望将结果存储在该类型的某个变量中。可以使用 as 运算符或强制来完成。例如:
var backgroundColor:uint = getStyle("backgroundColor") as int;
or
var backgroundColor:uint = int(getStyle("backgroundColor"));
如果在样式查找链中的任何位置都未设置样式属性,则 getStyle() 方法的返回值为 undefined。请注意,undefined 是一个特殊值,它与 false、空字符串 ("")、NaN、0 或 null不同。如果没有有效的样式值,则总是 undefined。可以使用静态方法 StyleManager.isValidStyleValue() 来测试是否设置了值。
参数
styleProp:String — 样式属性的名称。 |
* — 样式值。 |
| notifyStyleChangeInChildren | () | 方法 |
public function notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void向该组件的子项传送样式更改。
参数
styleProp:String — 样式属性的名称。 | |
recursive:Boolean — 是否将样式更改传播到子项的子项。 |
| regenerateStyleCache | () | 方法 |
public function regenerateStyleCache(recursive:Boolean):void
设置内部样式缓存值,以便 getStyle() 方法可以起作用。如果该对象已有子项,则重新初始化子项的样式缓存。
参数
recursive:Boolean — 重新生成子项的原始链。 |
| registerEffects | () | 方法 |
public function registerEffects(effects:Array):void将 EffectManager 注册为每个效果事件的事件侦听器之一。
参数
effects:Array — 效果名称的字符串 Array。 |
| setStyle | () | 方法 |
public function setStyle(styleProp:String, newValue:*):void对此组件实例设置样式属性。
这可能会覆盖以全局方式设置的样式。
调用 setStyle() 方法会降低性能。仅在必要时才使用它。
参数
styleProp:String — 样式属性的名称。 | |
newValue:* — 样式的新值。 |