Flex的 - URLLoader和的HTTPService [英] Flex - URLLoader and HTTPService

查看:195
本文介绍了Flex的 - URLLoader和的HTTPService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的URLLoader将数据加载到我的Flex应用程序(主要是XML)和我的朋友是谁在做同样的事情,大多采用的HTTPService。是否有使用上比其他特定的或有效的原因是什么?

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?

推荐答案

的HTTPService继承AbstractInvoker它允许您使用令牌和反应,你不能使用URLLoader使用。令牌是当你需要传递是相关的要求,你的反应想返回特定变量的好。

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.

除此之外,使用的URLLoader或HttpService的装载XML是相同的。

Other than that, using URLLoader or HttpService to load xml is the same.

例如:

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
));

这篇关于Flex的 - URLLoader和的HTTPService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆