Download presentation
Presentation is loading. Please wait.
Published byAngelica Washington Modified over 9 years ago
1
CSC 2720 Building Web Applications FLEX –Working with Remote Data
2
Connecting with HTTP Use HTTPService class to load any remote data via HTTP protocol Steps: Create an instance of HTTPService that maps to a URL. Invoke the send() method to retrieve the remote file asynchronously. Retrieve the loaded data via the lastResult property.
3
Loading an XML File students.xml
4
service.lastResult.students.student is an array of objects with each object containing three properties – name, id, age. The lastResult property holds the most recently retrieved data. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="service.send()"> <mx:DataGrid dataProvider="{service.lastResult.students.student}" >
5
HTTPService's resultFormat Property We can specify in what format the returned value should be using the property resultFormat. Possible values are: "object", "array", "xml", "flashvars", "text", "e4x". Default value is "object", which converts XML to a hierarchical list of ActionScript objects.
6
Retriving Results via a Handler Function <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="service.send()"> <mx:HTTPService url="students.xml" result="handleResult(event)" /> <![CDATA[ import mx.rpc.events.ResultEvent; private function handleResult(e:ResultEvent):void { var resultObj: Object = e.result; … } ]]>
7
Passing Parameters to the Server <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="sendRequest()"> <![CDATA[ private function sendRequest():void { var params: Object = new Object(); params.count = 10; // # of records params.min_age = 20; // minimum age service.send(params); // Use HTTP GET (default) } ]]>
8
References and Resources Adobe Flex 3.0 For Dummies, by Doug McCune, Deepa Subramaniam. Wiley Publishing, Inc. 2008
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.