天天看点

Styling Alert controls in Flex using the StyleManager class and setStyle() methods

The following example shows how you can style a Flex Alert control using the static <code>StyleManager.getStyleDeclaration()</code> method, and the <code>setStyle()</code> method

&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;!-- http://blog.flexexamples.com/2008/02/29/styling-alert-controls-in-flex-using-the-stylemanager-class-and-setstyle-methods/ --&gt;

&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

        layout="vertical"

        verticalAlign="middle"

        backgroundColor="white"

        creationComplete="init();"&gt;

    &lt;mx:Script&gt;

        &lt;![CDATA[

            import mx.controls.Alert;

            import mx.styles.StyleManager;

            private var alert:Alert;

            private var alertCSS:CSSStyleDeclaration;

            private function init():void {

                alertCSS = StyleManager.getStyleDeclaration("Alert");

            }

            private function showAlert(color:Object):void {

                alertCSS.setStyle("modalTransparencyColor", color);

                alertCSS.setStyle("themeColor", color);

                alert = Alert.show("The quick brown fox

Styling Alert controls in Flex using the StyleManager class and setStyle() methods

");

        ]]&gt;

    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;

        &lt;mx:Button label="Red"

                themeColor="red"

                click="showAlert('red');" /&gt;

        &lt;mx:Button label="Orange"

                themeColor="haloOrange"

                click="showAlert('haloOrange');" /&gt;

        &lt;mx:Button label="Yellow"

                themeColor="yellow"

                click="showAlert('yellow');" /&gt;

        &lt;mx:Button label="Green"

                themeColor="haloGreen"

                click="showAlert('haloGreen');" /&gt;

        &lt;mx:Button label="Blue"

                themeColor="haloBlue"

                click="showAlert('haloBlue');" /&gt;

    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;

    本文转自 OldHawk  博客园博客,原文链接:http://www.cnblogs.com/taobataoma/archive/2008/03/04/1089910.html,如需转载请自行联系原作者

继续阅读