Jul 20

接下来的例子演示了Flex中如何自定义Alert控件按钮(Button)样式,使其按钮边角更加圆滑。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


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

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>
代码:Peter deHaan 翻译/整理/编译:minidxer

written by Minidxer  |  tags: , , , ,

Related Post

Leave a Reply