Flex上传本地图片并提前浏览的实现方法(flex form)怎么可以错过

随心笔谈1年前 (2023)发布 admin
117 0

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx” minWidth=”955″ minHeight=”600″

creationComplete=”creationCompleteHandler(event)”>

import flash.net.FileReference;

import flash.net.FileFilter;

import flash.events.IOErrorEvent;

import flash.events.Event;

private var fr:FileReference;

private var imageTypes:FileFilter;

private function creationCompleteHandler(event:Event):void {

fr=new FileReference();

imageTypes=new FileFilter(“Images (*.jpg, *.jpeg, *.png, *.gif)”,”*.jpg; *.jpeg; *.png; *.gif;”)

fr.addEventListener(Event.SELECT, selectHandler);//增加当打开浏览文件后,用户选择好文件后的Listener

}

private function browseHandler(event:Event):void {

fr.browse([imageTypes]);//打开浏览文件的dialog

}

private function selectHandler(event:Event):void {

fr.addEventListener(Event.COMPLETE, onLoadComplete);//增加一个文件加载load完成后的listener

fr.load(); //加载用户选中文件

}

private function onLoadComplete(e:Event):void

{

imgPhoto.source=fr.data;

}

]]>

© 版权声明

相关文章