Showing posts with label Scale object size to stage size. Show all posts
Showing posts with label Scale object size to stage size. Show all posts

Monday, February 8, 2010

Scale object size to stage size

var sw:Number = stage.stageWidth,
var sh:Number = stage.stageHeight;

if( sw/sh < c.width/c.height ) // (or the opposite depending on the way of scaling)
{
    c.width = Math.min(origW,sw);
    c.scaleY = c.scaleX = Math.min(1, c.scaleX);
}
else
{
    c.height = Math.min(origH,sh);
    c.scaleX = c.scaleY = Math.min(1, c.scaleY);
}