Flex4 add event listener

1672 단어 listener
<?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">
	<fx:Script>
		<![CDATA[
			import mx.controls.Alert;
			
			protected function buttonClick():void
			{
				Alert.show("Button has been clicked");
				
			}
			
		]]>
	</fx:Script>
	<s:Button click="buttonClick()" label="Click Me" x="500" y="300"/>
</s:Application>

 
<?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">
	<fx:Script>
		<![CDATA[
			import mx.controls.Alert;
			
			protected function buttonClick(event:Event):void
			{
				if(event.target.id=="buttonOne"){
					Alert.show("ButtonOne has been clicked");
				}
				if(event.target.id=="buttonTwo"){
					Alert.show("ButtonTwo has been clicked");
				}
			}
		]]>
	</fx:Script>
	<s:Button click="buttonClick(event)" label="ButtonOne" 
			  x="500" y="300" id="buttonOne"/>
	<s:Button click="buttonClick(event)" label="ButtonTwo" 
			  x="600" y="300" id="buttonTwo"/>
</s:Application>

좋은 웹페이지 즐겨찾기