Get bitmap data dynamically


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



Copy this code and paste it in your HTML
  1. public static function getBitmapData(target:DisplayObjectContainer) : BitmapData
  2. {
  3. var bounds : Rectangle = new Rectangle();
  4. bounds = target.getBounds(target);
  5. var matrix : Matrix = new Matrix(1, 0, 0, 1, 0 - bounds.x, 0 - bounds.y);
  6. matrix.scale(1, 1);
  7. //for png data set the transparent to true, otherwise just leave as false
  8. var bmd : BitmapData = new BitmapData(bounds.width, bounds.height, true);
  9. bmd.draw(target, matrix, null, null, null, true);
  10. return bmd;
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.