Using movie clips to customize Button skins

The example above demonstrates how to use an ActionScript class to customize the Button skin, which is the method used by the skins provided in both the Halo and Sample themes. However, because the example uses simple colored boxes, it is simpler in this case to use different movie clip symbols as the skins.

To create movie clip symbols for Button skins:

  1. Select File > New and choose Flash File (ActionScript 2.0).
  2. Create a new symbol by selecting Insert > New Symbol.
  3. Set the name to RedButtonSkin.
  4. If the advanced view is not displayed, click the Advanced button.
  5. Select Export for ActionScript.

    The identifier is automatically filled out with RedButtonSkin.

  6. Set the Class to mx.skins.SkinElement.
  7. Make sure that Export in First Frame is already selected, and click OK.
  8. Open the new symbol for editing.
  9. Use the drawing tools to create a box with a red fill and black line.
  10. Set the border style to hairline.
  11. Set the box, including the border, so that it is positioned at (0,0) and has a width and height of 100.

    The SkinElement class resizes the content as appropriate.

  12. Repeat steps 2-11 and create green and blue skins, named accordingly.
  13. Click the Back button to return to the main timeline.
  14. Drag a Button component to the Stage.
  15. Set the toggled property value to true to see all three skins.
  16. Copy the following ActionScript code to the Actions panel with the Button instance selected.
    onClipEvent(initialize) {
        falseUpSkin = "BlueButtonSkin";
        falseDownSkin = "GreenButtonSkin";
        falseOverSkin = "BlueButtonSkin";
        falseDisabledSkin = "BlueButtonSkin";
        trueUpSkin = "RedButtonSkin";
        trueDownSkin = "RedButtonSkin";
        trueOverSkin = "RedButtonSkin";
        trueDisabledSkin = "RedButtonSkin";
    }
    
  17. Select Control > Test Movie.