是否可以在 Flex 中进行轻量级 REST 调用?
我们正在将 Flex 应用程序转换为使用一些 REST API。
将 mx.rpc.http.HTTPService
类添加到代码中后,SWF 二进制输出从 175KB 增加到 260KB。这是一个不可接受的打击。
有没有更好的方法从 Flex 应用程序执行轻量级 REST 调用?我们是否最好使用外部接口 JS 来进行调用?
We are converting a Flex application to use some REST APIs.
When adding the mx.rpc.http.HTTPService
class to the code, the SWF binary output grew from 175KB to 260KB. This is an unacceptable hit.
Is there any better way to do lightweight REST calls from a Flex app? Are we better off using an external interface JS just to make the calls from there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
flash.net.URLLoader
内置于运行时中,不会导致文件大小增加。我之前曾将它用作 JSON 客户端,因此您应该不会遇到任何问题。下面是一个非常简单的例子。请参阅
HTTP_STATUS
的文档 和HTTP_RESPONSE_STATUS
了解有关其限制的信息。
flash.net.URLLoader
is built into the runtime and won't cause any increase in filesize. I've used it as a JSON client before, so you shouldn't have any troubles with it.Below is a very simple example. See documentation for
HTTP_STATUS
andHTTP_RESPONSE_STATUS
for information on their restrictions.我一直认为一个好的方法是为浏览器的 JavaScript HTTP API XmlHttpRequest 创建一个小接口。我从未尝试过,但我研究过,看起来可能相当简单。
这将带来额外的好处,那就是绕过 Flash Player 的安全限制,这些限制使其 HTTP 支持严重受损。
I've always thought a good approach to this would be to create a small interface to the browser's JavaScript HTTP API, XmlHttpRequest. I've never tried it, but I've looked into it, and it looked like it might be fairly straightforward.
This would have the added benefit of working around Flash Player's security restrictions which make its HTTP support terribly crippled.