Using the setStyle() and getStyle() methods

You cannot get or set style properties directly on a component as you can with other properties. Instead, you set style properties at run time by using the getStyle() and setStyle() ActionScript methods. When you use the getStyle() and setStyle() methods, you can access the style properties of instances of objects or of style sheets.

Every Flex component exposes these methods. When you are instantiating an object and setting the styles for the first time, you should try to apply style sheets rather than use the setStyle() method because it is computationally expensive. This method should only be used when you are changing an object's styles during run time. For more information on improving performance with the setStyle() method, see Improving performance with the setStyle() method.

Subtopics

Setting styles
Improving performance with the setStyle() method

Flex 2.01

Take a survey