Flex中自定义Alert控件按钮(Button)样式的例子

2023-05-25 样式 自定义 控件

下面是完整代码(或点击这里察看):


Download: main.mxml



1. <?xml version="1.0" encoding="utf-8"?>
2. <mx:Application xmlns:mx="Http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white">
3.  
4.     <mx:Style>
5.         .roundedAlertButtons {
6.             cornerRadius: 10;
7.             font-weight: bold;
8.             color: black;
9.         }
10.     </mx:Style>
11.  
12.     <mx:Script>
13.         <![CDATA[
14.             import mx.controls.Alert;
15.  
16.             private var alert:Alert;
17.  
18.             private function showAlert():void {
19.                 alert = Alert.show("The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog.", "I'm an Alert control.", Alert.YES | Alert.NO);
20.                 alert.setStyle("buttonStyleName", "roundedAlertButtons");
21.             }
22.         ]]>
23.     </mx:Script>
24.  
25.     <mx:Button label="Show alert" click="showAlert();" />
26.  
27. </mx:Application>

相关文章