Hi,
i'm using Stage.scaleMode = "showAll"; to automatically resize my mc.
In the mc there's a menu bar which should stay the same size.
How do i do this?
Printable View
Hi,
i'm using Stage.scaleMode = "showAll"; to automatically resize my mc.
In the mc there's a menu bar which should stay the same size.
How do i do this?
Not possible, with showAll, the Stage dimensions don't change when resized, and neither can you apply an onResize listener!
If you're aiming for a fluid layout, where everything is positioned/sized based on the size of the stage, you might need to look at Stage.scaleMode = StageScaleMode.NO_SCALE. This mode means that nothing is scaled, however, so it could mess up your work flow.
You can, however, add an event listener for when the stage's size is adjusted (unlike with the showAll scale mode, that Nig 13 pointed out) so that you can adjust the size of your content. A basic example would be:
The stage.align property says that all objects are positioned from the top left, so at the very top left, x and y are 0. So placing menuBar at x = 0 will attach it to the left side of the stage, and resizing the width to equal the stage's width will simply stretch it out across the page.Code:stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeContent, false, 0, true);
function resizeContent(evt:Event):void{
menuBar.width = stage.stageWidth;
}
Here's a good site if you want to get another example (that's better easier to understand than mine too). http://www.kirupa.com/developer/as3/...tering_as3.htm
Great, Danny22, but maybe he's using AS2 since he mentioned this: Stage.scaleMode = "showAll";
It's a bit different in AS2, but the concept is the same:
Actionscript Code:Stage.scaleMode = "noScale";
Stage.align = "TL";
resizeListener = new Object();
resizeListener.onResize = function(){
// example code, this will align
// a movieclip to the center of your Flash
mc._x = Stage.width/2;
mc._y = Stage.height/2;
}
Stage.addListener(resizeListener);
There was a good tutorial in AS2 for this as well, but it was deleted recently :(
lol, but you know AS3, which is way more popular nowadays, so that's good