/*
You can responds to any stage resize event by proportionally scaling the image to fill the stage. Since scaleX and scaleY are percentages, it's just a matter of figuring out which property is larger and making the two equal. By swapping the scale comparison from greater than to less than, the object will scale proportionally to fit the larger of the two dimensions given. This kind of calculation is handy when you need to fit items of variable dimensions into a fixed space.
*/
// set image dimensions to match stage or the object you want to scale to;
image.width = stage.stageWidth; // Or object.width
image.height = stage.stageHeight; // Or object.height
// choose the larger scale property and match the other to it;
( image.scaleX < image.scaleY ) ? image.scaleY = image.scaleX : image.scaleX = image.scaleY;
// choose the smaller scale property and match the other to it;
( image.scaleX > image.scaleY ) ? image.scaleY = image.scaleX : image.scaleX = image.scaleY;