Image (Loader) to ByteArray


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import flash.display.Loader;
  2. import flash.display.LoaderInfo;
  3. import flash.events.Event;
  4. import flash.net.URLRequest;
  5. import flash.utils.ByteArray;
  6.  
  7. var loader:Loader = new Loader();
  8. loader.load(new URLRequest("banner1.jpg"));
  9. loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
  10.  
  11. private function loaderComplete(event:Event):void
  12. {
  13.     var loaderInfo:LoaderInfo = LoaderInfo(event.target);
  14.     var byteArray:ByteArray = loaderInfo.bytes;
  15.     // result: byteArray
  16. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.