Drawing a scaled object in Actionscript

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

Copy this code and paste it in your HTML
  1. public function drawScaled(obj:DisplayObject, thumbWidth:Number, thumbHeight:Number):Bitmap {
  2. var m:Matrix = new Matrix();
  3. m.scale(thumbWidth / obj.width, thumbHeight / obj.height);
  4. var bmp:BitmapData = new BitmapData(thumbWidth, thumbHeight, false);
  5. bmp.draw(obj, m);
  6. return new Bitmap(bmp);
  7. }

URL: http://www.nightdrops.com/2009/quick-reference-drawing-a-scaled-object-in-actionscript/

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.