在Flex中,用Web的開發環境中,
有辦法直接開啟本端照片嗎?
例如:
不知是否有辦法直接開啟,而不要先上傳再開啟~
因為當這樣指時,就會出現一段安全性的問題~
原文討論在這
最近實在太忙了,忙到連看Blog的留言有時候多要幾天才有機會看一次,今天趁著午休時間稍微快速的展示一下實際的作法,這個問題很單純也很簡單,
只要從本機端讀取內容呈現在Flash Player裡就可以,不過請注意以下的示範需要在Flash CS3或Flex
3.2以後的版本才能完成編譯的動作。
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" creationComplete="init()" backgroundColor="White"> <mx:Script> <![CDATA[ import mx.core.UIComponent; private var fileR:FileReference=new FileReference(); private function init():void { this.fileR.addEventListener(Event.SELECT, selectHandler); this.fileR.addEventListener(Event.COMPLETE, completeHandler); } private function selectHandler(event:Event):void { this.fileR.load(); } private function completeHandler(event:Event):void { this.imageShow.source=this.fileR.data; } private function showPic():void { this.fileR.browse(); } ]]> </mx:Script> <mx:Button label="Browse Image" click="showPic()"/> <mx:Image id="imageShow" width="200" height="200"/> </mx:Application>
|
展示效果請點擊下方測試:

Comment Permissions: Allow commenting