Alert消息框的使用

1、修改默认的按钮标签

      Alert.yesLabel = "是";
      Alert.noLabel = "否";
      Alert.okLabel = "确定";
      Alert.cancelLabel = "取消";

 

2、为按钮指定自定义事件

     Alert.show("确定要提交吗?", "提示", Alert.OK|Alert.CANCEL, null, alertClose);

 

     private function alertClose(event: CloseEvent):void{
           switch(event.detail){
                 case Alert.OK:
                       txt.text = "确定提交";
                       break;
                 case Alert.CANCEL:
                       txt.text = "取消提交";
                       break;
          }
     } 

 

3、设置icon图标

     [Bindable]
     [Embed(source='question.png')]
     private var Icon: Class;
 
     Alert.show("确定要提交吗?", "提示", Alert.OK|Alert.CANCEL, null, alertClose, Icon);

 

4、设定Alert的叠加层的颜色

     var alertCSS: CSSStyleDeclaration = StyleManager.getStyleDeclaration("Alert");
     alertCSS.setStyle("modalTransparencyColor", "haloOrange");
     alertCSS.setStyle("themeColor", "haloOrange");
    
     var alert:Alert = Alert.show("确定要提交吗?", "提示", Alert.OK|Alert.CANCEL, null, alertClose, Icon);

 

5、通过样式自定义Alert的风格

<mx:Style> 
	Alert { 
		buttonStyleName: myCustomButtonStyleName; 
		messageStyleName: myCustomMessageStyleName; 
		titleStyleName: myCustomTitleStyleName;
		
		backgroundAlpha: 0.3;  -- 指定背景色及其透明度
		backgroundColor: green; 
		borderAlpha: 0.3;   -- 指定边框色及其透明度
		borderColor: green; 
		dropShadowEnabled: true;  -- 是否有阴影
	} 
	
	--标题的样式
	.myCustomTitleStyleName { 
		color: haloOrange; 
		fontFamily: 宋体; 
		fontSize: 16; 
		fontWeight: normal; 
	} 
	
	--消息的样式
	.myCustomMessageStyleName { 
		color: haloGreen; 
		fontFamily: 宋体; 
		fontSize: 13; 
		fontWeight: normal; 
	} 

	--按钮的样式
	.myCustomButtonStyleName { 
		color: haloBlue; 
		cornerRadius: 12; 
		fontFamily: 宋体; 
		fontSize: 12; 
		fontWeight: bold; 
		textDecoration: underline; 
		themeColor: red; 
	} 
</mx:Style>

 

 

你可能感兴趣的:(Flex)