Posted By

xzkcz on 04/08/09


Tagged

preview localfile


Versions (?)

PreviewLocalImage


 / Published in: ActionScript 3
 

URL: http://blog.riaproject.com/flex/1012.html

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
  3. creationComplete="init()" backgroundColor="White">
  4.  
  5. <mx:Script>
  6. <![CDATA[
  7. import mx.core.UIComponent;
  8. private var fileR:FileReference=new FileReference();
  9.  
  10. private function init():void
  11. {
  12. this.fileR.addEventListener(Event.SELECT, selectHandler);
  13. this.fileR.addEventListener(Event.COMPLETE, completeHandler);
  14. }
  15.  
  16. private function selectHandler(event:Event):void
  17. {
  18. this.fileR.load();
  19. }
  20.  
  21. private function completeHandler(event:Event):void
  22. {
  23. this.imageShow.source=this.fileR.data;
  24. }
  25.  
  26. private function showPic():void
  27. {
  28. this.fileR.browse();
  29. }
  30. ]]>
  31. </mx:Script>
  32.  
  33. <mx:Button label="Browse Image" click="showPic()"/>
  34. <mx:Image id="imageShow" width="200" height="200"/>
  35.  
  36. </mx:Application>

Report this snippet  

You need to login to post a comment.