I managed to run across this code which resizes my background image to the size of the window, but it does not work well with vertical formatted images. It cuts off the bottom of the image when using this code.
stop();
Stage.scaleMode = "noScale";
Stage.align = "TL";
bg.onResize = function() {
var imageAspectRatio = bg._width / bg._height;
var stageAspectRatio = Stage.width / Stage.height;
if (stageAspectRatio >= imageAspectRatio) {
bg._width = Stage.width;
bg._height = Stage.width / imageAspectRatio;
} else {
bg._height = Stage.height;
bg._width = Stage.height * imageAspectRatio;
}
bg._x = Stage.width /2 ;
bg._y = Stage.height /2;
};
Stage.addListener(bg);
bg.onResize();
How could I change this code so that it will change the aspect ratio if there is a vertical image instead of horizontal? Instead of it cutting off the bottom of the image, I would rather it scale to the height and leave blanks areas to the right and left.
Thanks…