views:

39

answers:

2

Hey

I'm trying to create a small flash-app, which needs to run as big as possible on the browser. For example regexr and Grooveshark work this way. However, if I use the File -> Publish Settings and there set the width and height 100%, it resizes to full browser, but...

When I use stageHeight and stageWidth, they don't change. I only have one frame in my animation, so should I fire a eventListener for something like "resize"?

I've just started actionscript 3 so please don't provide too advanced stuff, at least without explaining.

Thanks, Martti Laine

+1  A: 

You're right -- there is, in fact, a resize event to listen for. For the stage to resize properly, though, you'll want to set the stage's scaleMode and align properties.

stage.scaleMode = StageScaleMode.NO_SCALE;    // Use NO_SCALE then resize your content manually to avoid stretching/pixelation
stage.align = StageAlign.TOP_LEFT;            // So that (0, 0) is always in the top-left corner

stage.addEventListener(Event.RESIZE, resizeOccurred);

function resizeOccurred(e:Event):void
{
    trace("New stage width: " + stage.stageWidth + "; new stage height: " + stage.stageHeight);
}
Cameron
Thanks a thousand times!
Martti Laine