HTTPService class can be used to make asychronous calls. send() method of the object is used to send the request. After data has been received, result event (ResultEvent) is broadcast. The result is stored in lastResult property. A resultFormat can be specified or Flex will parse it approproately. Format can be array, e4x, flashvars, object, text or xml.
Flex gives the flexibility to convert to native XML object (E4X) or to directly convert into a object(like ArrayCollection, XMLListCollection).
For automatic conversion, we will have a tag similar to this in the MXML:
<mx:HTTPService id="serviceId" url="http://www.myUrl.com/myXml.xml" result="handlingFunc(event)" fault="handleFault(event)"/>
Use fault event to handle errors. The event in this case will be FaultEvent and not ResultEvent
Questions:
- What are the advantages and disadvantages of using a Model tag in flex?
- How can you avoid using a Model tag?
- Describe in brief how HTTPService class works.
- What are possible result formats for HTTPService?
- What are the advantages of using HTTPService?
2 comments:
Do you know why an http service would return the same result after the initial .send(); was sent.
Its returns the same result even though the .php file returns new data upon execution.
I am not sure Nathan. Will have a look and get back if I get an answer
Post a Comment