I use URLLoader to load data into my Flex app (mostly XML) and my buddy who is doing the same thing mostly uses HTTPService. Is there a specific or valid reason to use on over the other?
A:
There really is no difference between using the two. Both implementations could be considered "correct".
James
2008-11-10 21:13:53
+5
A:
HTTPService inherits AbstractInvoker which allows you to use tokens and responders which you cannot use with URLLoader. Tokens are good when you need to pass specific variables that are relevant to the request, which you want returned with the response.
Other than that, using URLLoader or HttpService to load xml is the same.
Example:
var token:AsyncToken = httpService.send({someVariable: 123});
token.requestStartTime = getTimer();
token.addResponder(new AsyncResponder(
function (evt:ResultEvent, token:Object):void {
var xml:XML = evt.result as XML;
var startTime = token.requestStartTime;
var runTime = getTimer() - startTime;
Alert.show("Request took " + runTime + " ms");
//handle response here
},
function (info:Object, token:Object):void {
//handle fault here
},
token
));
maclema
2008-11-11 12:50:12
you are the man - thank you!
onekidney
2008-11-13 20:32:52