Using styles with the RadioButton

You can set style properties to change the appearance of a RadioButton. The ScrollPane's style properties specify values for its skins, icons, text formatting, and padding when the component is drawn. The ScrollPane's styles specify values for its skins and padding for its layout when the component is drawn.

The following example retrieves the textFormat style from a CheckBox component and applies it to a RadioButton to make the style of their labels identical.

To apply the textFormat style from a CheckBox to a RadioButton:

  1. Create a new Flash file (ActionScript 3.0).
  2. Drag a CheckBox component to the Stage and give it an instance name of myCh in the Property inspector.
  3. Drag a RadioButton to the Stage and give it an instance name of myRb in the Property inspector.
  4. Add the following code to the Actions panel on Frame 1 of the Timeline.
    var tf:TextFormat = new TextFormat();
    tf.color = 0x00FF00;
    tf.font = "Georgia";
    tf.size = 18;
    myCh.setStyle("textFormat", tf);
    myRb.setStyle("textFormat", myCh.getStyle("textFormat"));
    

    This code sets the textFormat style for the CheckBox, then applies it to the RadioButton by calling the getStyle() method on the CheckBox.

  5. Select Control > Test Movie.