Flex 4 사용자 정의 팝 업 알림 상자

3965 단어 flex4
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   applicationComplete="init()">
	<fx:Declarations>
		<!--  ビジュアルエレメント (サービス、 オブジェクトなど) をここに   -->
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.events.CloseEvent;
			
			[Bindable]
			[Embed(source="assets/bonus.png")]
			public var bonusIcon:Class;
			
			[Bindable]
			[Embed(source="assets/attention.png")]
			public var attentionIcon:Class;
			
			[Bindable]
			[Embed(source="assets/yes.png")]
			public var yesIcon:Class;
			
			[Bindable]
			[Embed(source="assets/no.png")]
			public var noIcon:Class;
			
			public var alert:Alert;
			
			protected function init():void
			{
				makesure.addEventListener(MouseEvent.CLICK,cmd_makesure);
				detail.addEventListener(MouseEvent.CLICK,cmd_detail);
			}
			
			protected function thisAlertClose(event:CloseEvent):void
			{
				// YES:uint = 0x0001;
				// NO:uint = 0x0002;
				// OK:uint = 0x0004;
				// CANCEL:uint = 0x0008;
				var result:uint = event.detail;
				var message:String="";
				// /         ,            ,                    
				switch (result)
				{
					case 1:
						message ="The selected one is :" +Alert.yesLabel;
						break;
					case 2:
						message ="The selected one is :" +Alert.noLabel;
						break;
					case 4:
						message ="The selected one is :" +Alert.okLabel;
						break;
					case 8:
						message ="The selected one is :" +Alert.cancelLabel;
						break;
				}
				Alert.show(message,"Result",Alert.OK,this,null,bonusIcon,Alert.OK);
			}
			
			protected function cmd_makesure(event:Event):void
			{
				//       YES,NO      
				Alert.show("Are you sure?","Make sure",Alert.YES|Alert.NO,this,thisAlertClose);
			}
			
			protected function cmd_detail(event:Event):void
			{
				Alert.buttonWidth = 150;
				Alert.okLabel = "Disneyland";
				Alert.yesLabel = "Kennedy Space Port";
				Alert.noLabel = "SIx Flags";
				Alert.cancelLabel = "Marine World";
				//  Alert.show    
				//text:String="", title:String="", flags:uint=4, parent:Sprite=null, (    ,  ,  【YES|NO|OK|CANCEL】,           )
				//closeHandler:Function=null, iconClass:Class=null, defaultButtonFlag:uint=4, (        ,  ,    )
				alert = Alert.show("Where do you want to go?","Destination",Alert.OK|Alert.YES|Alert.NO|Alert.CANCEL,
					this,thisAlertClose,attentionIcon,Alert.YES);
				alert.height = 150;
				alert.width = 700;
				//         ,           ,。       
				Alert.okLabel = "OK";
				Alert.yesLabel = "YES";
				Alert.noLabel = "NO";
				Alert.cancelLabel = "CANCEL";
			}
		]]>
	</fx:Script>
	<s:Panel id="mix" verticalCenter="0" horizontalCenter="0" title="Mix" width="450" height="300">
		<s:VGroup verticalCenter="0" horizontalCenter="0">
			<s:Button id="makesure" label="Make sure?" />
			<s:Button id="detail" label="Where to go?"/>
		</s:VGroup>
	</s:Panel>
</s:Application>

좋은 웹페이지 즐겨찾기