Follow Flex After Dark on Twitter

StyleManager

The StyleManager class in the mx.styles package is responsible for managing Styles for a Flex application.

The StyleManager class manages the following:

  • Which CSS style properties the class inherits
  • Which style properties are colors, and therefore get special handling
  • A list of strings that are aliases for color values

Because there needs to be only one instance of a StyleManager for an application, its functionality is provided via static functions (and you'll never need to create your own instance).

Loading Style Sheets

The loadStyleDeclarations() method is asynchronous, so it returns an instance of an EventDispatcher to monitor its progress. You can use this object to trigger events based on the progress of the style sheet's loading. You have access to the StyleEvent.PROGRESS, StyleEvent.COMPLETE, and StyleEvent.ERROR events during the loading process.

The following example shows how to monitor the loading of a style sheet:

   // start the asynchrounous loading of the style sheet
   var styleEvents:IEventDispatcher = 
      StyleManager.loadStyleDeclarations( "../assets/Styles.swf" );
   
   // register event listeners to monitor progress
   styleEvents.addEventListener( StyleEvent.PROGRESS, updateStyleProgress );
   styleEvents.addEventListener( StyleEvent.COMPLETE, updateStyleProgress );
   styleEvents.addEventListener( StyleEvent.ERROR, updateStyleProgress );
   
   ...
   
   public function updateStyleProgress( styleEvent:StyleEvent ):void
   {
      // ...
   }

Check out the Style Manager API Documentation for more information...

Related Links:

Related Docs
  • Flex StyleSheets StyleSheets define styles for Flex components and can be defined inline or loaded at run-time.
  • Flex Styles Styles is Flex are similar to CSS.
Recent Docs
Random Docs