Posted By

gimpyk on 04/01/11


Tagged

movieclip bitmap matrix


Versions (?)

Draw movieclip into a bitmap. Return bitmap in new movieclip.


 / Published in: ActionScript 3
 

  1. public function makeItABitmapMovieClip(dO:DisplayObject):MovieClip
  2. {
  3. var mc:MovieClip = new MovieClip();
  4. var myBitmapData:BitmapData = new BitmapData(dO.width, dO.height, true, 0x000000);
  5.  
  6. var rect:Rectangle = dO.getBounds(dO);
  7.  
  8. var m:Matrix = new Matrix();
  9. m.tx = -rect.x;
  10. m.ty = -rect.y;
  11.  
  12. myBitmapData.draw(dO, m);
  13.  
  14. var bmp:Bitmap = new Bitmap(myBitmapData);
  15. bmp.smoothing = true;
  16. mc.addChild(bmp);
  17. bmp.x = bmp.width/-2;
  18. bmp.y = bmp.height/-2;
  19.  
  20. return mc;
  21. }

Report this snippet  

You need to login to post a comment.