<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="vertical" width="450" height="200" paddingLeft="20" paddingTop="20" paddingRight="20" paddingBottom="20" backgroundColor="0xFFFFFF" viewSourceURL="srcview/index.html"> <mx:Script> <![CDATA[ import mx.rpc.http.HTTPService; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import StringUtils; private function getTinyURL():void { tinyURLService.url = "http://tinyurl.com/api-create.php?url=" + StringUtils.trim( longURL.text ); tinyURLService.send(); } private function onTinyURLResult( event:ResultEvent ):void { tinyURL.text = String( event.result ); } private function onTinyURLFault( event:FaultEvent ):void { tinyURL.text = String( event.fault ); } ]]> </mx:Script> <mx:HTTPService id="tinyURLService" resultFormat="text" result="onTinyURLResult( event )" fault="onTinyURLFault( event )" showBusyCursor="true" /> <mx:VBox> <mx:Label text="TinyURL Demo" fontSize="20" /> <mx:Label text="Type in URL" fontSize="12" /> <mx:HBox> <mx:TextInput id="longURL" width="300" /> <mx:Button label="Get TinyURL" click="getTinyURL()" /> </mx:HBox> <mx:Spacer height="20" /> <mx:Text id="tinyURL" fontSize="14" width="300" height="20" /> </mx:VBox> </mx:Application>