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

flex upLoadImg

发布时间:2020-12-15 05:15:36 所属栏目:百科 来源:网络整理
导读: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.eve

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); ??} ?? ?} }

(编辑:李大同)

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

    推荐文章
      热点阅读