You won't get anything from _loader.content *until* it's COMPLETE event fires, 
so add a listener for that and get it's content in the function you define in 
that listener.


-----Original Message-----
From: flexcoders@yahoogroups.com on behalf of markflex2007
Sent: Fri 07/11/2008 19:57
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: show local image in AIR application.
 

I try this but I can not get bitmap.why?Thanks for help.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
 <mx:Script>
        <![CDATA[
                
                 import flash.filesystem.File;  
         import mx.controls.Alert; 
         
         private var _loader:Loader;
         private var _importFile:File;
         private var _bitmap:Bitmap;
         private var _bitmapData:BitmapData;
   
         private function browseFile():void  
         {  
             _importFile = new File();  
             _importFile.addEventListener(Event.SELECT, openOutput);  
             _importFile.browseForOpen("Select a File",[new
FileFilter( "Image File", "*.jpg;*.jpeg;" )]);  
         }  
   
         private function openOutput(e:Event):void  
         {  
             fileloc.text = e.target.nativePath;
             //
             _loader = new Loader();
             _bitmap = new Bitmap();
             
             _loader.load( new URLRequest(_importFile.url ));
             
             _bitmap = _loader.content as Bitmap;
             _bitmapData = _bitmap.bitmapData;
        }  
                
                
        ]]>
</mx:Script>

    
    <mx:TextInput width="289" x="10" y="3" id="fileloc" />  
    <mx:Button click="browseFile()" label="Browse for File" x="10"
y="46" />  
 
  
 </mx:WindowedApplication>




______________________________________________________________________
This communication is from Primal Pictures Ltd., a company registered in 
England and Wales with registration No. 02622298 and registered office: 4th 
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT 
registration No. 648874577.

This e-mail is confidential and may be privileged. It may be read, copied and 
used only by the intended recipient. If you have received it in error, please 
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 
1010. Please then delete the e-mail and do not disclose its contents to any 
person.
This email has been scanned for Primal Pictures by the MessageLabs Email 
Security System.
______________________________________________________________________

<<winmail.dat>>

Reply via email to