Flex 3文件下载 - 没有URLRequest [英] Flex 3 file download - Without URLRequest

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

问题描述

我的Flex客户端应用程序从后端获取了一些数据(RemoteObjects,BlazeDS,Spring)。客户端已经获得了所有需要的数据,现在需要将一些CSV格式的信息提供给下载。



为此使用Flex 3。任何想法?



谢谢,
Sri

解决方案

如果您正在为Flash Player 10进行编译,那么您可以调用 FileReference.save()函数来保存到本地文件系统:



http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/flash/net/FileReference.html#save()



只要确保你记下这一节:


在Flash Player中,您只能成功响应一个用户来调用此方法事件(例如,在鼠标点击或按键事件的事件处理程序中)。否则,调用此方法会导致Flash Player抛出错误异常。此限制不适用于应用程序沙箱中的AIR内容。


唯一的其他替代方法,如果您无法为Flash Player 10编译是将数据发送到服务器,让用户以CSV格式从那里下载数据。



您可以使用 FileReference.download () save()
http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3 /flash/net/FileReference.html#download()


My Flex client app has got some data from the back end (RemoteObjects, BlazeDS, Spring). Client has got all the data it needs, it now needs to put some information in a CSV format and make it available for download.

Using Flex 3 for this. Any ideas?

Thanks, Sri

解决方案

If you are compiling for Flash Player 10 then you can call the FileReference.save() function to save to the local file-system:

http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/flash/net/FileReference.html#save()

Just make sure you take note of this section:

In Flash Player, you can only call this method successfully in response to a user event (for example, in an event handler for a mouse click or keypress event). Otherwise, calling this method results in Flash Player throwing an Error exception. This limitation does not apply to AIR content in the application sandbox.

The only other alternative if you can't compile for Flash Player 10 is to send the data to the server and have the user download it from there as a CSV.

You can do this with the FileReference.download() in a simlar manner to save(): http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/flash/net/FileReference.html#download()

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

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