Hi all (again), I have a problem with the resizing function of a fullscreen website.
I had this code, it works OK
Stage.scaleMode = "noScale";
Stage.align = "TL";
function toStage(mc:MovieClip, xPos:Number, yPos:Number, mcWidth:Number, mcHeight:Number) {
mc._x = Math.floor(xPos);
mc._y = Math.floor(yPos);
mc._width = mcWidth;
mc._height = mcHeight;
}
function toStageFullscreen(mc:MovieClip) {
if (Stage.height/Stage.width>0.75) {
toStage(mc,0,0,Stage.height/0.75,Stage.height);
} else {
toStage(mc,0,0,Stage.width,Stage.width*0.75);
}
}
function init(){
//Stage objects
toStage(background,0,0,Stage.width,Stage.height);
attachMovie("img","img",1)
toStageFullscreen(img);
if (Stage.height/Stage.width>0.75) {
toStage(mc,Stage.width/2-mc._width/2,Stage.height/2-mc._height/2,Stage.height/0.75,Stage.height);
} else {
toStage(mc,Stage.width/2-mc._width/2,Stage.height/2-mc._height/2,Stage.width,Stage.width*0.75);
}
}
var stageListener:Object = new Object();
stageListener.onResize = function() {
toStageFullscreen(img);
if (Stage.height/Stage.width>0.6) {
toStage(mc,Stage.width/2-mc._width/2,Stage.height/2-mc._height/2,Stage.height/0.75,Stage.height);
} else {
toStage(mc,Stage.width/2-mc._width/2,Stage.height/2-mc._height/2,Stage.width,Stage.width*0.75);
}
};
Stage.addListener(stageListener);
Now this attaches the Background image to the topleft corner of the browser - meaning that it cuts the background picture on the right and bottom side if the browser is resized smaller than the picture that is loaded into it.
So I changed the function for position / size to this:
function toStageFullscreen(mc:MovieClip) {
if (Stage.height/Stage.width>0.75) {
toStage(mc,Stage.width/2-mc._width/2,Stage.height/2-mc._height/2,Stage.height/0.75,Stage.height);
} else {
toStage(mc,Stage.width/2-mc._width/2,Stage.height/2-mc._height/2,Stage.width,Stage.width*0.75);
}
}
and it does exactly what it should. Reference point now is the center of the picture, so when the browser is resized, the picture always stays in the middle, and resizing cuts on all 4 sides equally. Only problem is that when I use the browser’s maximize button, the picture keeps it’s size and position - it doesn’t resize. It only does if I pull the browser to size manually.
Can somebody please help me with this? I’m stuck…
You can have a look at it here: www.bartproeve.com/bldlngtest (pull the browser window smaller, then press the browser’s maximize button).
Thanks a lot!
B