# Scaling background and not content

**URL:** <https://forum.kirupa.com/t/scaling-background-and-not-content/183221>\
**Category:** flash\
**Created:** [March 24, 2006, 7:22pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221 "2006-03-24T19:22:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![larsk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@larsk](https://forum.kirupa.com/u/larsk)\
**Post date:** [March 24, 2006, 7:22pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/1 "2006-03-24T19:22:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bokke](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Bokke](https://forum.kirupa.com/u/Bokke)\
**Post date:** [March 24, 2006, 9:16pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/2 "2006-03-24T21:16:50Z")

</div>

Check [COLOR=DarkOrange]**[www.gotoAndLearn.com](http://www.gotoandlearn.com)**[/COLOR] and click on Full Browzer Flash. 😉

---

<div class="post-metadata">

**Author:** ![larsk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@larsk](https://forum.kirupa.com/u/larsk)\
**Post date:** [March 24, 2006, 9:55pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/3 "2006-03-24T21:55:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![v2ikematu](https://avatars.discourse-cdn.com/v4/letter/v/3d9bf3/32.png) [@v2ikematu](https://forum.kirupa.com/u/v2ikematu)\
**Post date:** [March 24, 2006, 10:03pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/4 "2006-03-24T22:03:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![larsk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@larsk](https://forum.kirupa.com/u/larsk)\
**Post date:** [March 24, 2006, 10:05pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/5 "2006-03-24T22:05:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![v2ikematu](https://avatars.discourse-cdn.com/v4/letter/v/3d9bf3/32.png) [@v2ikematu](https://forum.kirupa.com/u/v2ikematu)\
**Post date:** [March 24, 2006, 10:12pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/6 "2006-03-24T22:12:13Z")

</div>

then it’s easy as that:

```auto

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);
}

```

---

<div class="post-metadata">

**Author:** ![larsk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@larsk](https://forum.kirupa.com/u/larsk)\
**Post date:** [March 25, 2006, 11:20am UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/7 "2006-03-25T11:20:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![larsk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@larsk](https://forum.kirupa.com/u/larsk)\
**Post date:** [March 25, 2006, 1:56pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/8 "2006-03-25T13:56:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![this](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/this/32/669_2.png) [@this](https://forum.kirupa.com/u/this)\
**Post date:** [March 25, 2006, 2:29pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/9 "2006-03-25T14:29:58Z")

</div>

sees my code.

---

<div class="post-metadata">

**Author:** ![larsk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@larsk](https://forum.kirupa.com/u/larsk)\
**Post date:** [March 25, 2006, 3:59pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/10 "2006-03-25T15:59:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bokke](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Bokke](https://forum.kirupa.com/u/Bokke)\
**Post date:** [March 25, 2006, 4:37pm UTC](https://forum.kirupa.com/t/scaling-background-and-not-content/183221/11 "2006-03-25T16:37:39Z")

</div>

> [@larsk](#):
>
> Sorry, but somehow I cannot download your file.  
> Any other way to see it?  
> Thanks  
> Lars

try turning off your firewall 😉
