Using styles in Flex 4

January 27th, 2011 by aabhaanjan

We can modify the appearance of components through style properties.

Important points :

  1. The style properties that we can set on a component depend on the component’s architecture.
  2. The components in the MX component set (mx.controls.* and mx.containers.* packages) take one set of styles. Components in the Spark component set (spark.components.* package) allow an entirely different set of styles.
  3. Flex does not support controlling all aspects of component layout with CSS.
  4. Properties such    as xywidth, and height are properties, not styles, of the UIComponent class, and therefore cannot be set in CSS.
  1. For MX components to use CSS it should  implement the IStyleClient interface.

Example :


<?xml version=”1.0″?>

<!– modules/StyleModLoaderApp.mxml –>









@namespace s “library://”;

s|Button {





<s:Button id=”myButton” label=”Sample Styling”/>



Tags: , , , ,