OldHawk

菜地一块,欢迎拍砖
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Styling the Alert control’s status message

Posted on 2008-01-11 09:55  OldHawk  阅读(334)  评论(0编辑  收藏  举报
The following example shows how you can customize the appearance of the status message in an Alert control in Flex by setting the statusStyleName style and status property
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/03/styling-the-alert-controls-status-message/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white"
        creationComplete
="init();">

    
<mx:Style>
        @font-face {
            src: local("Comic Sans MS");
            fontFamily: myComicSansMS;
            fontWeight: normal;
        }

        Alert {
            statusStyleName: myCustomStatusStyleName;
        }

        .myCustomStatusStyleName {
            color: red;
            fontFamily: myComicSansMS;
            fontSize: 10;
            fontWeight: normal;
        }
    
</mx:Style>

    
<mx:Script>
        
<![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);
                alert.status = "status message";
            }
        
]]>
    
</mx:Script>

    
<mx:ApplicationControlBar dock="true">
        
<mx:Button label="Launch alert" click="init();" />
    
</mx:ApplicationControlBar>

</mx:Application>