패키지 | mx.styles |
클래스 | public class CSSStyleDeclaration |
상속 | CSSStyleDeclaration EventDispatcher Object |
하위 클래스 | AdvancedDataGridColumn, DataGridColumn |
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
A CSS rule such as
Button { color: #FF0000 }affects every instance of the Button class; a selector like
Button
is called a type selector
and must not start with a dot.
A CSS rule such as
.redButton { color: #FF0000 }affects only components whose
styleName
property
is set to "redButton"
;
a selector like .redButton
is called a class selector
and must start with a dot.
You can access the autogenerated CSSStyleDeclaration objects
using the StyleManager.getStyleDeclaration()
method,
passing it either a type selector
var buttonDeclaration:CSSStyleDeclaration = StyleManager.getStyleDeclaration("Button");or a class selector
var redButtonStyleDeclaration:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".redButton");
You can use the getStyle()
, setStyle()
,
and clearStyle()
methods to get, set, and clear
style properties on a CSSStyleDeclaration.
You can also create and install a CSSStyleDeclaration at run time
using the StyleManager.setStyleDeclaration()
method:
var newStyleDeclaration:CSSStyleDeclaration = new CSSStyleDeclaration(".bigMargins"); newStyleDeclaration.defaultFactory = function():void { leftMargin = 50; rightMargin = 50; } StyleManager.setStyleDeclaration(".bigMargins", newStyleDeclaration, true);
기타 예제
관련 API 요소
속성 | 정의 주체 | ||
---|---|---|---|
constructor : Object
지정된 객체 인스턴스의 클래스 객체 또는 생성자 함수에 대한 참조입니다. | Object | ||
defaultFactory : Function
This function, if it isn't null,
is usually autogenerated by the MXML compiler. | CSSStyleDeclaration | ||
factory : Function
This function, if it isn't null,
is usually autogenerated by the MXML compiler. | CSSStyleDeclaration | ||
overrides : Object
If the setStyle() method is called on a UIComponent or CSSStyleDeclaration
at run time, this object stores the name/value pairs that were set;
they override the name/value pairs in the objects produced by
the methods specified by the defaultFactory and
factory properties. | CSSStyleDeclaration | ||
selector : CSSSelector
This property is the base selector of a potential chain of selectors
and conditions that are used to match CSS style declarations to
components. | CSSStyleDeclaration | ||
selectorIndex : int = 0
The order this CSSStyleDeclaration was added to its StyleManager. | CSSStyleDeclaration | ||
specificity : int [읽기 전용]
Determines the order of precedence when applying multiple style
declarations to a component. | CSSStyleDeclaration | ||
subject : String [읽기 전용]
The subject describes the name of a component that may be a potential
match for this style declaration. | CSSStyleDeclaration |
메서드 | 정의 주체 | ||
---|---|---|---|
CSSStyleDeclaration(selector:Object = null, styleManager:IStyleManager2 = null, autoRegisterWithStyleManager:Boolean = true)
Constructor. | CSSStyleDeclaration | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
리스너에서 이벤트 알림을 받을 수 있도록 EventDispatcher 객체에 이벤트 리스너 객체를 등록합니다. | EventDispatcher | ||
Clears a style property on this CSSStyleDeclaration. | CSSStyleDeclaration | ||
이벤트를 이벤트 흐름으로 전달합니다. | EventDispatcher | ||
Gets the value for a specified style property,
as determined solely by this CSSStyleDeclaration. | CSSStyleDeclaration | ||
EventDispatcher 객체에 특정 유형의 이벤트에 대한 리스너가 등록되어 있는지 여부를 확인합니다. | EventDispatcher | ||
지정된 속성이 객체에 정의되어 있는지 여부를 나타냅니다. | Object | ||
Object 클래스의 인스턴스가 매개 변수로 지정된 객체의 프로토타입 체인에 있는지 여부를 나타냅니다. | Object | ||
Determines whether this style declaration applies to the given component
based on a match of the selector chain. | CSSStyleDeclaration | ||
지정된 속성이 존재하고 열거 가능한지 여부를 나타냅니다. | Object | ||
EventDispatcher 객체에서 리스너를 제거합니다. | EventDispatcher | ||
루프 작업에서 동적 속성을 사용할 수 있는지 여부를 설정합니다. | Object | ||
Sets a style property on this CSSStyleDeclaration. | CSSStyleDeclaration | ||
로캘별 규칙에 따라 서식이 지정된 이 객체의 문자열 표현을 반환합니다. | Object | ||
지정된 객체의 문자열 표현을 반환합니다. | Object | ||
지정된 객체의 프리미티브 값을 반환합니다. | Object | ||
이 EventDispatcher 객체 또는 조상 객체에 지정한 이벤트 유형에 대한 이벤트 리스너가 등록되어 있는지 여부를 확인합니다. | EventDispatcher |
defaultFactory | 속성 |
defaultFactory:Function
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
This function, if it isn't null
,
is usually autogenerated by the MXML compiler.
It produce copies of a plain Object, such as
{ leftMargin: 10, rightMargin: 10 }
,
containing name/value pairs for style properties; the object is used
to build a node of the prototype chain for looking up style properties.
If this CSSStyleDeclaration is owned by a UIComponent written in MXML, this function encodes the style attributes that were specified on the root tag of the component definition.
If the UIComponent was written in ActionScript,
this property is null
.
구현
public function get defaultFactory():Function
public function set defaultFactory(value:Function):void
factory | 속성 |
factory:Function
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
This function, if it isn't null
,
is usually autogenerated by the MXML compiler.
It produce copies of a plain Object, such as
{ leftMargin: 10, rightMargin: 10 }
,
containing name/value pairs for style properties; the object is used
to build a node of the prototype chain for looking up style properties.
If this CSSStyleDeclaration is owned by a UIComponent, this function encodes the style attributes that were specified in MXML for an instance of that component.
구현
public function get factory():Function
public function set factory(value:Function):void
overrides | 속성 |
overrides:Object
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
If the setStyle()
method is called on a UIComponent or CSSStyleDeclaration
at run time, this object stores the name/value pairs that were set;
they override the name/value pairs in the objects produced by
the methods specified by the defaultFactory
and
factory
properties.
구현
public function get overrides():Object
public function set overrides(value:Object):void
selector | 속성 |
selector:CSSSelector
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 4 |
런타임 버전: | Flash Player 10, AIR 1.5 |
This property is the base selector of a potential chain of selectors and conditions that are used to match CSS style declarations to components.
구현
public function get selector():CSSSelector
public function set selector(value:CSSSelector):void
selectorIndex | 속성 |
public var selectorIndex:int = 0
The order this CSSStyleDeclaration was added to its StyleManager. MatchStyleDeclarations has to return the declarations in the order they were declared
specificity | 속성 |
subject | 속성 |
subject:String
[읽기 전용] 언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 4 |
런타임 버전: | Flash Player 10, AIR 1.5 |
The subject describes the name of a component that may be a potential match for this style declaration. The subject is determined as right most simple type selector in a potential chain of selectors.
구현
public function get subject():String
CSSStyleDeclaration | () | 생성자 |
public function CSSStyleDeclaration(selector:Object = null, styleManager:IStyleManager2 = null, autoRegisterWithStyleManager:Boolean = true)
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
Constructor.
매개 변수selector:Object (default = null ) — - If the selector is a CSSSelector then advanced
CSS selectors are supported. If a String is used for the selector then
only simple CSS selectors are supported. If the String starts with a
dot it is interpreted as a universal class selector, otherwise it must
represent a simple type selector. If not null, this CSSStyleDeclaration
will be registered with StyleManager.
| |
styleManager:IStyleManager2 (default = null ) — - The style manager to set this declaration into. If the
styleManager is null the top-level style manager will be used.
| |
autoRegisterWithStyleManager:Boolean (default = true ) — - If true set the selector in the styleManager. The selector
will only be set if both selector and styleManager are
both non-null.
|
clearStyle | () | 메서드 |
getStyle | () | 메서드 |
public function getStyle(styleProp:String):*
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
Gets the value for a specified style property, as determined solely by this CSSStyleDeclaration.
The returned value may be of any type.
The values null
, ""
, false
,
NaN
, and 0
are all valid style values,
but the value undefined
is not; it indicates that
the specified style is not set on this CSSStyleDeclaration.
You can use the method StyleManager.isValidStyleValue()
to test the value that is returned.
매개 변수
styleProp:String — The name of the style property.
|
* — The value of the specified style property if set,
or undefined if not.
|
matchesStyleClient | () | 메서드 |
public function matchesStyleClient(object:IAdvancedStyleClient):Boolean
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 4 |
런타임 버전: | Flash Player 10, AIR 1.5 |
Determines whether this style declaration applies to the given component based on a match of the selector chain.
매개 변수
object:IAdvancedStyleClient — The component to match the style declaration against.
|
Boolean — true if this style declaration applies to the component,
otherwise false.
|
setStyle | () | 메서드 |
public function setStyle(styleProp:String, newValue:*):void
언어 버전: | ActionScript 3.0 |
제품 버전: | Flex 3 |
런타임 버전: | Flash Player 9, AIR 1.1 |
Sets a style property on this CSSStyleDeclaration.
매개 변수
styleProp:String — The name of the style property.
| |
newValue:* — The value of the style property.
The value may be of any type.
The values null , "" , false ,
NaN , and 0 are all valid style values,
but the value undefined is not.
Setting a style property to the value undefined
is the same as calling the clearStyle() method.
|
Tue Jun 12 2018, 03:17 PM Z