I’m trying to resize a full flash site. I’m using if statements to do this. Is there a better way? I want the resize to hold the proportions. Additionally, my if-statement method is too cumbersome. It doesn’t always keep the content in the center (doesn’t resize to the content to be in the center).
Scenario: The base is a black background that resizes according to the window size. The main image stays in the middle of the page.
var holderAllMC:MovieClipLoader = new MovieClipLoader();
var holderAllMCListener:Object = new Object();
holderAllMCListener.onLoadProgress = function(target, loaded, total) {
loader.percent.text = Math.round((loaded/total)*100)+"%";
};
holderAllMC.addListener(holderAllMCListener);
holderAllMC.loadClip("background.swf?uniqueID="+getTimer(), holderAll.subholder);
holderAllMCListener.onLoadInit = function() {
loader._visible = false;
loader.percent.text = "";
resizeSite();
};
backs._width = Stage.width;
backs._height = Stage.height;
loader._x = Stage.width/2;
loader._y = Stage.height/2.5;
function resizeSite() {
var wwn:Number = Stage.width;
var hhn:Number = Stage.height;
var wwnd:Number = 840;
var hhnd:Number = 608;
if (wwn<=500) {
holderAll._xscale = 60;
holderAll._yscale = 60;
holderAll._x = Stage.width/2;
holderAll._y = Stage.height/2.5;
}
if (hhn<=450) {
holderAll._xscale = 60;
holderAll._yscale = 60;
holderAll._x = Stage.width/2;
holderAll._y = Stage.height/2.5;
} else if (wwn<=840) {
holderAll._xscale = 90;
holderAll._yscale = 90;
holderAll._x = Stage.width/2;
holderAll._y = Stage.height/2.5;
} else if (hhn<=608) {
holderAll._xscale = 90;
holderAll._yscale = 90;
holderAll._x = Stage.width/2;
holderAll._y = Stage.height/2.5;
} else if (wwn>840) {
holderAll._xscale = 100;
holderAll._yscale = 100;
holderAll._x = Stage.width/2;
holderAll._y = Stage.height/2.5;
} else if (hhn>608 && hhn<725) {
holderAll._xscale = 100;
holderAll._yscale = 100;
holderAll._x = Stage.width/2;
holderAll._y = Stage.height/2.5;
} else if (hhn>725) {
holderAll._xscale = 140;
holderAll._yscale = 140;
holderAll._x = Stage.width/2;
holderAll._y = Stage.height/3.5;
}
}
var stageL:Object = new Object();
stageL.onResize = function() {
backs._width = Stage.width;
backs._height = Stage.height;
loader._x = Stage.width/2;
loader._y = Stage.height/2.5;
resizeSite();
};
Stage.addListener(stageL);