Thursday, March 31, 2011

How can i get a BitmapData object out of a File object from a local jpeg file in AIR?

So I am trying to create an image gallery. My AIR application accepts files that are dragged and dropped onto a TileList component. I am using the images as icons but the problem is that they take a long time to load so i want to compress the file data first (I have that part done) The problem is that I can't figure out how to open the file and put the data into a BitmapData object.

Any ideas?

From stackoverflow
  • var req:URLRequest = new URLRequest(value.file.url);
    var ldr:Loader = new Loader();
    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
    ldr.load(req);
    .
    .
    .
    private function completeHandler(event:Event):void {
      var ldr:Loader = Loader(event.target.loader);
      var b:Bitmap = Bitmap(ldr.content);
    }
    

0 comments:

Post a Comment