Setting a style for all components

You can set a style for all component using the static setStyle() method of the StyleManager class.

To set a style for all components:

  1. Drag a List component to the Stage and give it an instance name of aList.
  2. Drag a Button component to the Stage and give it an instance name of aButton.
  3. Press F9 or select Actions from the Window menu to open the Actions panel, if it isn't already open, and enter the following code in Frame 1 of the Timeline to set the color of text to red for all components:
    import fl.managers.StyleManager;
    
    var tf:TextFormat = new TextFormat();
    tf.color = 0xFF0000;
    StyleManager.setStyle("textFormat", tf);
    
  4. Add the following code to the Actions panel to populate the List with text.
    aList.addItem({label:"1956 Chevy (Cherry Red)", data:35000});
    aList.addItem({label:"1966 Mustang (Classic)", data:27000});
    aList.addItem({label:"1976 Volvo (Xcllnt Cond)", data:17000});
    aList.allowMultipleSelection = true;
    
  5. Select Control > Test Movie or press Ctrl+Enter to compile the code and test your content. The text in both the button label and in the list should be red.