加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex 上传文件预览

发布时间:2020-12-15 04:47:16 所属栏目:百科 来源:网络整理
导读:as 文件: // 文件浏览上传 import flash.net.FileFilter; import flash.net.FileReference; private var file:FileReference= new FileReference(); private var file2:FileReference= new FileReference(); private var file3:FileReference= new FileRefe

as文件:

//文件浏览上传

import flash.net.FileFilter;

import flash.net.FileReference;

privatevar file:FileReference=new FileReference();

privatevar file2:FileReference=new FileReference();

privatevar file3:FileReference=new FileReference();

privatevar file4:FileReference=new FileReference();

?

privatefunction look(str:String):void

{

??? //localChoose.addEventListener(MouseEvent.CLICK,doSelect);

??? //选择要上传文件的类型

??? var imageTypes:FileFilter=new FileFilter("图片 (*.jpg,*.jpeg,*.gif,*.png)", "*.jpg; *.jpeg; *.gif; *.png");

??? var textTypes:FileFilter=new FileFilter("文本文件(*.txt","*.txt;");

??? var officeType:FileFilter=new FileFilter("Office文件(*.doc,*.xls","*.doc; *.xls");

??? var anyType:FileFilter=new FileFilter("所有文件(*.*)","*.*");

??? var allTypes:Array=new Array(imageTypes,textTypes,officeType,anyType);

??? file.browse(allTypes);

??? file.addEventListener(Event.SELECT,onSelect);

?

//submitBtn.addEventListener(MouseEvent.CLICK,doUpload);

?

}

?

?

privatefunction look2(str:String):void

{

??? //localChoose.addEventListener(MouseEvent.CLICK, "*.jpg; *.jpeg; *.gif; *.png");

??? var allTypes:Array=new Array(imageTypes);

??? file2.browse(allTypes);

??? file2.addEventListener(Event.SELECT,onSelect02);

?

?? //submitBtn.addEventListener(MouseEvent.CLICK,doUpload);

?

}

privatefunction look3(str:String):void

{

??? //localChoose.addEventListener(MouseEvent.CLICK,doSelect);

??? //选择要上传文件的类型

??? var officeType:FileFilter=new FileFilter("Office文件(*.doc,"*.doc; *.xls");

??? var allTypes:Array=new Array(officeType);

??? file3.browse(allTypes);

??? file3.addEventListener(Event.SELECT,onSelect03);

?

?? //submitBtn.addEventListener(MouseEvent.CLICK,doUpload);

?

}

privatefunction look4(str:String):void

{

??? //localChoose.addEventListener(MouseEvent.CLICK,doSelect);

??? //选择要上传文件的类型

??? var anyType:FileFilter=new FileFilter("所有文件(*.*)","*.*");

??? var allTypes:Array=new Array(anyType);

??? file4.browse(allTypes);

??? file4.addEventListener(Event.SELECT,onSelect04);

?

?? //submitBtn.addEventListener(MouseEvent.CLICK,doUpload);

?

}

publicfunction onSelect(evt:Event):void

{

?

??? localPath01.text=file.name;

}

publicfunction onSelect02(evt:Event):void

{

??? localPath02.text=file2.name;

}

publicfunction onSelect03(evt:Event):void

{

??? localPath03.text=file3.name;

}

publicfunction onSelect04(evt:Event):void

{

??? localPath04.text=file4.name;

}

publicfunction doUpload(event:Event):void

{

??? if (localPath01.text =='')

??? {

??? ??? Alert.okLabel="";

??? ??? Alert.show("请选择要上传的文件!","警告");

??? }

??? else

??? {

??? ??? Alert.show("上传成功");

??? }

?

}

?

mxml文件:

??? <mx:FormItem label="附件:">

?????????? ?????? ??? <mx:HBox>

?????????? ?????????? ??? <mx:TextInput width="500"

?????????? ?????????? ?????????? ??? ? height="80"

?????????? ?????????? ?????????? ??? ? id="localPath04"/>

?????????? ?????????? ??? <mx:Button label="浏览..."

?????????? ?????????? ?????????? ?? click="look4('04')"/>

?????????? ?????? ??? </mx:HBox>

?????????? ??? ??? </mx:FormItem>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读