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 开发者_StackOverflowsomething like "resize"?
I've just started actionscript 3 so please don't provide too advanced stuff, at least without explaining.
Thanks, Martti Laine
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);
}
By full browser size do you actually mean fullscreen?
If yes add this listener to stage too:
stage.addEventListener(FullScreenEvent.FULL_SCREEN, resizeHandler);
Interestingly Flash doesn't consider going to fullscreen as a normal resize. And don't forget about imports on the top of your class:
import flash.events.Event;
import flash.events.FullScreenEvent;
Otherwise I agree with Cameron.
精彩评论