Simple UI Event
Example 1
Example 2
- A click event is created by clicking the button
- The click event triggers an asynchronous HTTPService call
- The HTTPService call waits for a response
- The result event (response) triggers the event handler
Example1.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ import mx.controls.Alert; private function myHandleClick(event:Event):void { Alert.show("Clicked!"); } ]]> </mx:Script> <mx:Button id="myButton" label="Create Click Event" click="myHandleClick(event)" /> </mx:Application>
Rendered sample
Example 2
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="#FFFFFF" backgroundAlpha="0"> <mx:HTTPService id="twitterService" url="http://twitter.com/statuses/public_timeline.xml" resultFormat="e4x" result="twitterServiceResultHandler(event)" /> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; private function twitterServiceResultHandler(event:ResultEvent):void { resultTxt.text = event.result.toString(); } ]]> </mx:Script> <mx:Button id="myButton" label="Send HTTP Request" click="twitterService.send()" /> <mx:TextArea id="resultTxt" fontSize="12" width="100%" height="100%" /> </mx:Application>


No comments:
Post a Comment