Clearing a style on the Spark Button control in Flex 4

The following example shows how you can clear a style on the Spark Button control in Flex 4 by using the clearStyle() method.

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see To download the latest nightly build of the Flex 4 SDK, see

For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:Application name="Spark_Button_clearStyle_test"
        <s:Button label="bold" fontWeight="bold" click="btn.setStyle('fontWeight', FontWeight.BOLD);" />
        <s:Button label="no bold" click="btn.clearStyle('fontWeight');" />
            import flash.text.engine.FontWeight;
    <s:Button id="btn"
            horizontalCenter="0" verticalCenter="0" />

This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.

3 thoughts on “Clearing a style on the Spark Button control in Flex 4

  1. Thanks for your site and all the great examples!

    Is it possible to clear a style setting in an external CSS file? I would like to clear the “alternatingItemColors” style property on the Spark mobile LabelItemRenderer class so it would have a transparent background.

    I also want to be able to switch app-wide styling by loading one external CSS file or another, so using the clearStyle() method in code isn’t an option.

  2. To clarify my question, what would I put in my CSS file (excerpt below) to clear the existing property setting?

    alternatingItemColors : ???;

Comments are closed.