<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" > <mx:Script><![CDATA[ import mx.rpc.events.ResultEvent; [Bindable] private var _sClientIPUrl:String ="http://localhost:8600/myip.jsp"; /**//** Runs on creationComplete */ private function initApp():void ...{ dsClientIP.send(); //invokes the data service call } /**//** called by the result event of the data service call */ private function onResult(oEvent:ResultEvent):void ...{ var xmlResult:XML = XML(oEvent.result); //get the result as XML //trace(xmlResult); var sIp:String = xmlResult.@clientIP; //get the attribute value //trace(sIp); lbIP.text = sIp; //display it } ]]></mx:Script> <mx:Label id="lbIP" fontSize="26"/> <mx:Button x="20" y="20" label="send" click="initApp();"/> <mx:HTTPService id="dsClientIP" url="{_sClientIPUrl}" result="onResult(event)" resultFormat="e4x"/> </mx:Application>