
120 Styles and Skinning
Using the StyleManager
When you use the StyleManager to apply styles to entire classes, you must now access the class
with the
getStyleDeclaration() method. For example:
Flex 1.x:
StyleManager.styles.Button.setStyle("color","red");
Flex 2:
StyleManager.getStyleDeclaration("Button").setStyle("color","red");
You can no longer set or get styles as properties of a component or class. You now use
setStyle() and getStyle(). This also applies to using StyleManager. While accessing styles
this way was discouraged in Flex 1.5, it was not prohibited until now.
Flex 1.x:
var c = myButton.color;
StyleManager.styles.TextArea.color = "red";
Flex 2:
var c:Number = myButton.getStyle("color");
StyleManager.getStyleDeclaration("TextArea").setStyle("color","red");
In addition, you can no longer create a CSSStyleDeclaration object and then apply it to a type
of control, as the following example shows:
public var styleObj:CSSStyleDeclaration = new CSSStyleDeclaration();
styleObj.setStyle("color","red");
styleObj.setStyle("fontFamily","Tahoma");
StyleManager.styles.Accordion = styleObj;
You must now use the setStyle() method; for example:
StyleManager.getStyleDeclaration("Accordion").setStyle("color","red");
StyleManager.getStyleDeclaration("Accordion").setStyle("fontFamily","Tahoma
");
You can also use the StyleManager.setStyleDeclaration() method.
The
getNonInheritingStyle() and getInheritingStyle() methods were removed. You
can now use the
getStyle() method instead.
Commentaires sur ces manuels