Obeying browser text size changes when using noScale
The answer to the question is that, yes, this method will work when using noScale and you can decide exactly how to handle the layout of your SWF when the stage size changes.
Here's the example from the previous post, refactored with some custom scaling code: You can view the example online and download the source code.
This is a snippet of just the custom scaling code from the above example:
[as]
// The scale mode is set to no scale
Stage.scaleMode = "noScale";
Stage.align = "TL";
// Listen for resize events
Stage.addListener(this);
var margin:Number = 20; // pixels, same on all sides
// Calculate aspect ratio of the text items clip
// so we don't distress the text while scaling
var textItemsAspectRatio = textItems._height/textItems._width;
// Ditto for the picture
var pictureAspectRatio = picture._height/picture._width;
function onLoad()
{
// Carry out the resize code for the first time.
onResize();
}
// Custom layout code
function onResize()
{
// Store the stage dimensions as we'll be
// using them frequently
var sw:Number = Stage.width;
var sh:Number = Stage.height;
// Scale the background
background._x = 0;
background._y = 0;
background._width = sw;
background._height = sh;
// Scale the text. This is a quick and dirty way of
// doing it and it distresses the text
textItems._x = margin;
textItems._y = margin;
textItems._width = sw - (margin*2);
textItems._height = textItems._width * textItemsAspectRatio;
// Scale the picture
picture._y = textItems._y + textItems._height;
picture._x = margin;
picture._width = sw - (margin*2);
picture._height = picture._width * pictureAspectRatio;
// If you think this is a lot of work (and it is),
// check out how easy it is to do the same thing
// with layout constraints in Flex 2.
}
[/as]
Wow, it had been a long time since I'd written any custom scaling code. Makes you realize how much simpler life is with Flex 2 and its awesome layout constraints.
The Obeying browser text size changes when using noScale article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.

mike lyda
little bit of JavaScript http://www.alistapart.com/articles/fontresizing in the host HTML page to tell it when the user has resized the browser text, and some code to increase/decrease the Flash font sizes when that event is fired and it’d be golden.
September 26th, 2006 at 1:51 pmaral
Mike: That’s exactly what it’s doing!
Take a look at my previous post and Niqui’s post that’s linked from there.
September 26th, 2006 at 2:12 pmmike lyda
oops.. sorry about that.. I was just looking at this post and it looked like it did an initial resize and reacts to the browser resizing, but didn’t react to the user changing the browser font size.
September 26th, 2006 at 2:31 pmBob Corporaal
I have just release the source for the example discussed in the previous post. It can be found here: http://reefscape.net/?p=4
An updated demo can be found here: http://reefscape.net/things/flash/textresize/
September 27th, 2006 at 12:02 amIn this case the font size is not only adjusted with the height but the Flash div height changes as well so the browser scrollbar can be used.
aral
Thanks for the update, Bob!
September 28th, 2006 at 12:19 am