<?xml version=
"1.0" encoding=
"utf-8"?>
<s:Application xmlns:fx=
"http://ns.adobe.com/mxml/2009"
xmlns:s=
"library://ns.adobe.com/flex/spark"
xmlns:mx=
"library://ns.adobe.com/flex/mx" minWidth=
"955" minHeight=
"600"
creationComplete=
"init(event)">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:layout>
<s:VerticalLayout gap=
"5"/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
private var fr : FileReference;
private var imageType : FileFilter;
protected function clickHandler(event:MouseEvent):void
{
fr.browse([imageType]);
}
protected function init(event:FlexEvent):void
{
fr =
new FileReference();
imageType =
new FileFilter(
"Images (*.jpg, *.jpeg, *.png, *.gif)",
"*.jpg; *.jpeg; *.png; *.gif;");
fr.addEventListener(Event.SELECT,selectHandler);
}
private function selectHandler(event:Event):void{
fr.addEventListener(Event.COMPLETE,oncompleteHandler);
fr.load();
}
private function oncompleteHandler(event:Event):void{
imageId.source=fr.data;
}
]]>
</fx:Script>
<s:Button click=
"clickHandler(event)" label=
"加载图片"/>
<s:Image id=
"imageId"/>
</s:Application>
不得不说,flex大势已去,但是公司产品用的是这个就得上啊,HTML5大行其道,最新版谷歌浏览器已经不支持flash了,所以,flex能不做就别做了。
转载请注明原文地址: https://ju.6miu.com/read-1300222.html