Posted By

Heol on 06/23/11


Tagged

ByteArray bitmapData


Versions (?)

ByteArray to BitmapData


 / Published in: ActionScript 3
 

URL: http://blog.yoz.sk/2009/10/bitmap-bitmapdata-bytearray/

  1. import flash.display.Loader;
  2. import flash.display.LoaderInfo;
  3. import flash.events.Event;
  4. import flash.display.BitmapData;
  5.  
  6. var loader:Loader = new Loader();
  7. loader.loadBytes(byteArray);
  8. loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
  9.  
  10. private function loaderComplete(event:Event):void
  11. {
  12.     var loaderInfo:LoaderInfo = LoaderInfo(event.target);
  13.     var bitmapData:BitmapData = new BitmapData(loaderInfo.width, loaderInfo.height, false, 0xFFFFFF);
  14.     bitmapData.draw(loaderInfo.loader);
  15.     // result: bitmapData
  16. }

Report this snippet  

You need to login to post a comment.