flex文件下载
1flex端
<mx:Button label="下 载" click="download()"/>
//下载
public function download():void{
var str:String=this.uploadfiles.selectedIndex.toString();
if(str=="-1"){
Alert.show("请选中要下载的文件");
}else{
downloadfiles();
}
}
public function downloadfiles():void{
var loadid:String=this.uploadfiles.selectedItem.loadid;
if(loadid==null || loadid==""){
Alert.show("对不起,该文件还未上传");
}
var urlAddress:String=model.root+"/uploadFiles.do?method=download&loadid="+loadid;
//URLRequest可以捕获单个HTTP的所有信息
var url:URLRequest=new URLRequest(urlAddress);
var loadname:String=this.uploadfiles.selectedItem.loadname;
//download()方法提示用户提供文件的保存位置并开始从远程 URL 进行下载。
filedown.download(url,loadname);
}
protected override function createChildren():void{
super.createChildren();
filedown.addEventListener(Event.COMPLETE,onDownCompleted);
}
public function onDownCompleted(evt:Event):void{
this.resultlabel.visible=true;
var fileref:FileReference = evt.currentTarget as FileReference;
resultlabel.text = "文件名:" + uploadfiles.selectedItem.loadname+ "下载完毕!";
}
java后台(action)
/**
* 文件下载
*
* @param mapping
&nb
相关文档:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute" xmlns:ns1="com.component.*">
<mx:Script>
<![CDATA[
import com.component.DataHBox;
import com.component. ......
第一步: *.mxml文件中
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
creationComplete="playLoad()" color="#0F7085" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]">
<m ......
1、mian.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="HTTPSrv.send();" width="242" height="442">
<mx:Script>
<!--[CDATA[
import mx.rpc.events.ResultEv ......
2004年3月,Macromedia(2005年被Adobe收购)发布了Flex 1.0。从那时起,基于Flex的RIA开发获得了越来越多的动力,RIA也已经成为广泛接受的Web应用开发方式。今年,Adobe将发布Flex 4,随之而来的是Flash Builder 4以及Flash Catalyst,他们都将成为Adobe Flash Platform技术的组成部分。
Flex开发环境
Adobe Flex ......