popUpMenuButton

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:PopUpMenuButton x="43" y="39" id="PopUpMenuButton" dataProvider="{arr}" label="nihao" itemClick="test(event)" >
		
	</mx:PopUpMenuButton>
	<mx:MenuBar x="147" y="39" id="menu" dataProvider="{arr}"></mx:MenuBar>
	
	<mx:PopUpButton x="43" y="173" id="popUpBUtton">
		
	</mx:PopUpButton>
	
	<mx:Script>
		<![CDATA[
			import mx.events.MenuEvent;
			import mx.events.ItemClickEvent;
			import mx.controls.Menu;
			[Bindable]
			public var arr:Array=[
                {label: "Inbox", data: "inbox1"},
                {label: "Calendar", data: "calendar1"}, 
                {label: "Sent", data: "sent1"},
                {label: "Deleted Items", data: "deleted1"},
                {label: "Spam", data: "spam1"}
            ];
            private function test(event:MenuEvent){
            	trace(event.target.label);//nihao
            	trace(PopUpMenuButton.selectedField)//null
            	trace("s:"+PopUpMenuButton.selectedField);//null
            	trace(Menu(PopUpMenuButton.popUp).selectedItem.data.toString());//sent1

            }

		]]>
	</mx:Script>
	<mx:Array id="arr2">
		<mx:Object>
			你好
		</mx:Object>
		<mx:Object>
			buhao
		</mx:Object>
	</mx:Array>
	<mx:ArrayCollection id="arr1">
		<mx:source>
			<mx:Object>
			你好
		</mx:Object>
		<mx:Object>
			buhao
		</mx:Object>
		</mx:source>
	</mx:ArrayCollection>
</mx:Application>

 

你可能感兴趣的:(xml,Adobe)