天天看點

Styling the Alert control’s message text

The following example shows how you can customize the appearance of the message text in an Alert control in Flex by setting the <code>messageStyleName</code> style

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

&lt;!-- http://blog.flexexamples.com/2008/01/03/styling-the-alert-controls-message-text/ --&gt;

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

        layout="vertical"

        verticalAlign="middle"

        backgroundColor="white"

        creationComplete="init();"&gt;

    &lt;mx:Style&gt;

        @font-face {

            src: local("Comic Sans MS");

            fontFamily: myComicSansMS;

            fontWeight: normal;

        }

            fontWeight: bold;

        Alert {

            messageStyleName: myCustomMessageStyleName;

        .myCustomMessageStyleName {

            color: haloOrange;

            fontSize: 10;

    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;

        &lt;![CDATA[

            import mx.controls.Alert;

            private var alert:Alert;

            private function init():void {

                var myMessage:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\nDonec tincidunt sollicitudin sem.";

                var myTitle:String = "The quick brown fox jumped over the lazy dog";

                alert = Alert.show(myMessage, myTitle);

            }

        ]]&gt;

    &lt;/mx:Script&gt;

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

        &lt;mx:Button label="Launch alert" click="init();" /&gt;

    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;

    本文轉自 OldHawk  部落格園部落格,原文連結:http://www.cnblogs.com/taobataoma/archive/2008/01/11/1034746.html,如需轉載請自行聯系原作者

繼續閱讀