package com.wks.util
{
import com.wks.common;
import flash.events.ErrorEvent;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.net.FileFilter;
import flash.net.FileReference;
import flash.net.FileReferenceList;
import mx.containers.Tile;
import mx.controls.Alert;
public class UpLoadImg extends EventDispatcher
{
private var file:FileReferenceList;
private var bro_loc_2:*;
private var photoList:Tile;
private var autoClean:Boolean;
public var fileNum:int;
public var type:String;
public var cakeName:String;
private var tileStyle:Object={width:926,height:417,tileHeight:125,tileWidth:125,backgroundColor:"#00737373",borderStyle:"solid",cornerRadius:5,paddingLeft:5,paddingTop:5};
/**初始化上传图片类**/
public function UpLoadImg(type:String, target:IEventDispatcher=null, tile:Tile=null, tileStyle:Boolean=false, isClean:Boolean = false)
{
super(target);
this.type = type;
this.photoList = tile;
autoClean = isClean;
setPhotoListStyle(tileStyle);
this.file = new FileReferenceList();
this.configureListeners(this.file);
var _loc_1:* = new FileFilter(common.uploadTypeName, common.uploadType);
bro_loc_2 = new Array(_loc_1);
}
private function setPhotoListStyle(isSet:Boolean):void
{
if(photoList != null && isSet == true)
{
photoList.width = tileStyle.width;
photoList.height = tileStyle.height;
photoList.tileHeight = tileStyle.tileHeight;
photoList.tileWidth = tileStyle.tileWidth;
photoList.setStyle("backgroundColor",tileStyle.backgroundColor);
photoList.setStyle("borderStyle",tileStyle.borderStyle);
photoList.setStyle("paddingLeft",tileStyle.paddingLeft);
photoList.setStyle("paddingTop",tileStyle.paddingTop);
photoList.setStyle("cornerRadius",tileStyle.cornerRadius);
}
}
/**浏览要上传的图片**/
public function browseFile():void
{
this.file.browse(bro_loc_2);
}
/**上传图片**/
public function uploadFile(tile:Tile = null) : void
{
if(tile == null)
{
tile = photoList;
}
var _loc_3:photo = null;
var _loc_1:* = tile.getChildren();
var _loc_2:int = 0;
while (_loc_2 < _loc_1.length)
{
_loc_3 = _loc_1[_loc_2] as photo;
_loc_3.cakeIndex = (_loc_2+1).toString();
_loc_3.upfile();
_loc_2++;
}
}
private function configureListeners(param1:IEventDispatcher) : void
{
param1.addEventListener(Event.SELECT, this.selectHandler);
param1.addEventListener(IOErrorEvent.IO_ERROR, this.IoErr);
}
private function selectHandler(event:Event) : void
{
if(autoClean)
{
photoList.removeAllChildren();
}
var _loc_3:FileReference = null;
var _loc_4:photo = null;
var _loc_2:int = 0;
while (_loc_2 < this.file.fileList.length)
{
_loc_3 = FileReference(this.file.fileList[_loc_2]);
_loc_4 = new photo();
_loc_4.file = _loc_3;
_loc_4.type = this.type;
_loc_4.cakeName = this.cakeName;
fileNum = fileNum+1;//设置文件个数
photoList.addChild(_loc_4);
_loc_4.addEventListener(MouseEvent.CLICK, this.ShowPic);
_loc_2++;
if(type == "")
{
break;
}
}
}
private function ShowPic(event:MouseEvent) : void
{
return;
}
private function IoErr(event:ErrorEvent) : void
{
Alert.show(common.ImgUpLoadError, common.SystemInfo);
}
}
}
flex upLoadImg
原创
©著作权归作者所有:来自51CTO博客作者x_jie130的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:flex Validators
下一篇:flex app
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Flex实践——Flex+Jsp+EJB
这次的实践源于在线电子辞典的应用,这项目的完成者为 我( meteorlWJ)、elevenXL,sya
flex jsp ejb 数据库 mysql -
FLEX:随心所欲FLEX皮肤-FLEX皮肤教程
这是看到关于FLEX皮肤设计方面最好的教程了:利用外部导入SWF文件或者PNG文件,与CSS文件相结合,改变FLEX皮肤样式.
FLEX皮肤 FLEX skin FLEX皮肤教程 css html