Scaling background and not content

Hi,

I want only the background of my movie to be fullscreen and scaleable; the content should stay the same size.
I have tried a couple of scripts like this one:

BG = pathToYourBackGroundMC;//Change this line!!!
Stage.scaleMode = “noScale”;
Stage.align = ‘TL’;
resizeListen = new Object();
resizeListen.onResize = function(){
BG._width = Stage.width;
BG._height = Stage.height;
BG._x-= BG.getBounds(_root).xMin;
BG._y-= BG.getBounds(_root).yMin;
}
Stage.addListener(resizeListen);

or this one:

function initialize()
{
startingSizeX = Stage.width; // get these values before setting noScale
startingSizeY = Stage.height;
Stage.scaleMode = “noScale”; // prevent menus from resizing
backdrop._width = Stage.width;
backdrop._height = Stage.height;
menu1originalX = 20; // save original pos
menu1originalY = 50; // "
menu2originalX = 477; // "
menu2originalY = 50; // "
positionMenus(); // adjust menu position

// watch for resizing.  When it occurs, resize the background picture to match the stage size.
// All the other objects remain the same size but we reposition the objects by the amount needed.
listener = new Object();
listener.onResize = function ()
{
	// keep the background picture the same size as the stage
	backdrop._width = Stage.width;
	backdrop._height = Stage.height;
	positionMenus(); // reposition the menus as needed
};
Stage.addListener(listener);

}

function positionMenus()
{
// how much difference is stage size now compared to the original size?
var diffSizeX = startingSizeX - Stage.width;
var diffSizeY = startingSizeY - Stage.height;

// add half the difference to the menu position
menu1._x = menu1originalX + (diffSizeX / 2);
menu1._y = menu1originalY + (diffSizeY / 2);
menu2._x = menu2originalX - (diffSizeX / 2);
menu2._y = menu2originalY + (diffSizeY / 2);
}

None worked. Isn’t there a more simple Actionscript?
I’d appreciate any help.
Thanks in advance
Lars

Check [COLOR=DarkOrange]www.gotoAndLearn.com[/COLOR] and click on Full Browzer Flash. :wink:

Thanks, but my background consists only of one image (.jpg)
that needs to be scaled.

so you want your background to be tiled? like repeated?

No. I want the background scaled, when you change the window size of your browser. It does not matter when the background does not keep its proportions.

then it’s easy as that:


Stage.scaleMode ="noScale"; // no scaling
Stage.align = "TL"; //top-left alignment
var oStageListener:Object = new Object();
Stage.addListener(oStageListener);
oStageListener.onResize = function():Void
{
	mcBackground._x = 0;
	mcBackground._y = 0;
	mcBackground._width = Stage.width;
	mcBackground._height = Stage.height;
	/*-------*/
	/* aligning the content movieclip that should be named as mcContentHolder. Just in case you might be using pixelfonts, we're rounding the _x and _y values. */
	mcContentHolder._x = Math.round(Stage.width/2+mcContentHolder._width/2);
	mcContentHolder._y = Math.round(Stage.height/2+mcContentHolder._height/2);
}

Sorry for answering late.
Thank you very much, but when I try it I get the following error message:

Error Scene=Scene 1, layer=Layer 1, frame=1:Line 7: Operator ‘=’ must be followed by an operand
mcBackground._x = 0;

Error Scene=Scene 1, layer=Layer 1, frame=1:Line 8: Syntax error.
mcBackground._y = 0;

Total ActionScript Errors: 2 Reported Errors: 2

Any Idea?

I tried this now and so farit seems to work:

Stage.scaleMode = “noScale”;

reSizeFunction = function() {

//Gradient Bit
_root.bg_gradient._height = Stage.height;
_root.bg_gradient._y = 0-((Stage.height - 768)/2);
_root.bg_gradient._width = Stage.width;
_root.bg_gradient._x = 0-((Stage.width - 1024)/2) ;

}

myEye = new Object();
Stage.addListener(myEye);
myEye.onResize = reSizeFunction;

_root.bg_gradient._height = Stage.height;
_root.bg_gradient._y = 0;
_root.bg_gradient._width = Stage.width;
_root.bg_gradient._x = 0-((Stage.width - 1024)/2) ;

I hope it does the job; if not I will post this question again (this is not a threat). Thank you for all the help.
Bye Lars

sees my code.

Sorry, but somehow I cannot download your file.
Any other way to see it?
Thanks
Lars

try turning off your firewall :wink: