Given: A Flex TileList with the following event:
<mx:nativeDragDrop> <![CDATA[ if(event.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT)) { var files:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array; for each(var file:File in files) { // file.data is null here! } this.listData.refresh(); } ]]> </mx:nativeDragDrop>
I am trying to create a list of thumbnails from jpegs that I drag into this TileList. Image.source can use the url to show the image, but I need to scale the image down first (hi rez photos) I already have the scaling part done except that I need BitmapData from the file and it has null for file.data.
ALSO, I have tried this:
var x:URLRequest = new URLRequest(value.file.url); // this is a local file (e.g. file:///C:/somefile.jpg) var b:Bitmap = new Bitmap(x.data as BitmapData);
data is ALSO null! So frustrating. Any help would be appreciated.
I assume this is a part of an AIR application. (Accessing the clipboard from a plain Flex app is not possible.)
I have no experience with AIR, but your second code block is clearly wrong. An
URLRequestinstance does nothing in itself, it is but a static object storing the request details. In order to fetch the data from that URL, you need to create aLoader, and pass the request to that loader like this:Of course, you’d have to fill in the
Event.COMPLETEhandler. Note that theLoaderclass can be used to load SWF and image objects, for all everything else, you’d have to useURLLoaderand parse the data yourself.Regarding the
nativeDragDropblock, here’s a snippet from the documentation:Are you calling
NativeDragManager.acceptDrop()properly?