import flash.events.Event;
import flash.events.IEventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.SecurityErrorEvent;
import flash.net.FileReference;
import flash.net.URLRequest;
import mx.controls.Alert;
public class FileDownLoad
{
private var downloadURL:URLRequest;
private var fileName:String = "Doc2.docx";
private var file:FileReference;
public function FileReference_download():void {
downloadURL = new URLRequest();
downloadURL.url = "http://localhost:8080/taecs-web/Doc2.docx";
file = new FileReference();
configureListeners(file);
file.download(downloadURL,fileName);
}
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.CANCEL, cancelHandler);
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
dispatcher.addEventListener(Event.OPEN, openHandler);
dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
dispatcher.addEventListener(Event.SELECT, selectHandler);
}
private function cancelHandler(event:Event):void {
trace("cancelHandler: " + event);
}
private function completeHandler(event:Event):void {
trace("completeHandler: " + event);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
private function openHandler(event:Event):void {
trace("openHandler: " + event);
}
private function progressHandler(event:ProgressEvent):void {
var file:FileReference = FileReference(event.target);
trace("progressHandler name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function selectHandler(event:Event):void {
var file:FileReference = FileReference(event.target);
trace("selectHandler: name=" + file.name + " URL=" + downloadURL.url);
}
}
分享到:
相关推荐
NULL 博文链接:https://jhaij.iteye.com/blog/707088
[Flash Builder 4 and Flex 4 Bible] Flex 4 宝典 配套代码
一.flex2的全屏代码 在仅仅使用Flex Builder2(我下载的是FLXB_2.0_Win_WWE.exe)的时候,写全屏代码竟然找不到flash.display.StageDisplayState,于是下载了Flex 2.0.1升级包(官方地址:...flexbuilder2_201updater.exe...
Flex教程系列, 本教程是郑岩峰老师的教程, 我只是借花献佛。 Flex教程系列之(一) AS3语法——编程基础 http://download.csdn.net/source/1161756 Flex教程系列之(二) AS3语法——流程控制语句 ...
flex的linux包是一种词法分析程序生成器
很好的flex4入门教程,适合初学者。flex是较好的web开发技术,本书详细的描述了开发环境和开发过程中所需要的相关技术。
《Flex 4权威指南》是Adobe公司的官方教程,以课程的形式逐步讲解了如何用Flex 4开发一个完整的网上杂货商店应用程序,这个杂货商店能够动态显示数据和图像,并帮助用户完成结账流程,到数据提交至服务器为止。...
Flex4权威指南英文原版高清晰 Flex4权威指南英文原版高清晰
好不容易找到的 flex
NULL 博文链接:https://summerbell.iteye.com/blog/359226
非常方便入门或进阶学习,免去复制粘贴的麻烦和出错。 基于目前最新版本arcgis api for flex 3.3(可从http://download.csdn.net/detail/haoamz14/5327205下载),包含官网 ...
Version 3.7 To begin developing with the ArcGIS Viewer for Flex ("Viewer"), you should be familiar with the following: •ArcGIS Viewer for Flex basics ...•ArcGIS API for Flex - download API library
Flex 自定义布局 FlowLayout SnakeLayout CircleLayout RectangleLayout 官方下载地址:http://flexlayouts.org/download/
abode flex BlazeDS 源码
Flex教程系列, 本教程是郑岩峰老师的教程, 我只是借花献佛。 Flex教程系列之(一) AS3语法——编程基础 http://download.csdn.net/source/1161756 Flex教程系列之(二) AS3语法——流程控制语句 ...
These templates, in conjunction with the Flex Component Kit for Flash CS3 Professional, enable you to create and export a skin in Flash CS3 and then ...Download for Windows and Macintosh (MXP, 4.44 MB)
是 http://download.csdn.net/detail/zhaoshansanxia/4115320 的Intellij IDEA 版本 如果了解IDEA 可以只下载一个即可!所需的jar包都包含在上面地址的源码中
Adobe Flex4.0 ActionScript3 中文API 语言参考.part1.rar的下载地址: http://download.csdn.net/source/3245173 Adobe Flex4.0 ActionScript3 中文API 语言参考.part2.rar的下载地址: ...
这个是国外的一个收费的用于VS下的Flex插件,有了他,你就可以在VS下轻松快捷的开发flex程序了。压缩包里是最新的注册机。此注册机可用于VS2008和VS...http://www.sapphiresteel.com/Download-Amethyst-Adobe-Flex-IDE
flex4官方最新中文API CHM版,这是第二部分 第一部分的地址在 http://download.csdn.net/source/2676055