接下来的例子演示了Flex中如何自定义Alert控件按钮(Button)样式,使其按钮边角更加圆滑。
让我们先来看一下Demo (
可以右键View Source或点击这里 察看源代码):
下面是完整代码(或点击这里 察看):
Download:
main.mxml
- <? xml version = " 1.0 " encoding = " utf-8 " ?>
- < mx:Application xmlns:mx = " http://www.adobe.com/2006/mxml " layout = " vertical " verticalAlign = " middle " backgroundColor = " white " >
- < mx:Style >
- .roundedAlertButtons {
- cornerRadius: 10;
- font-weight: bold;
- color: black;
- }
- </ mx:Style >
- < mx:Script >
- <![CDATA[
- import mx.controls.Alert;
- private var alert:Alert;
- private function showAlert():void {
- 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);
- alert.setStyle("buttonStyleName", "roundedAlertButtons");
- }
- ]]>
- </ mx:Script >
- < mx:Button label = " Show alert " click = " showAlert(); " />
- </ mx:Application >