You can define how your swf is resized in your container (html, ..) by using :
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.scaleMode can be :
- StageScaleMode.EXACT_FIT—The entire application is visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, and the application may appear stretched or compressed.
- StageScaleMode.SHOW_ALL—The entire application is visible in the specified area without distortion while maintaining the original aspect ratio of the application. Borders can appear on two sides of the application.
- StageScaleMode.NO_BORDER—The entire application fills the specified area, without distortion but possibly with some cropping, while maintaining the original aspect ratio of the application.
- StageScaleMode.NO_SCALE—The entire application is fixed, so that it remains unchanged even as the size of the player window changes. Cropping might occur if the player window is smaller than the content.
If you want to control resize of each clip you have into your flash, use StageScaleMode.NO_SCALE. Be careful to ajust all clip in your flash ! “Cropping might occur if the player window is smaller than the content.”
You may define the align of the stage :
stage.align = StageAlign.TOP_LEFT;
More informations on align stage at http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#align
Then add a listener for resize event :
// import flash.events.Event; // import flash.display.StageScaleMode; // import flash.display.StageAlign; // Dispatched when the scaleMode property of the Stage object is set // to StageScaleMode.NO_SCALE and the SWF file is resized. stage.addEventListener(Event.RESIZE, stageHasBeenResized);
And here’s how to resize your clips depending on the size of the stage :
function stageHasBeenResized(e:Event):void {
trace("stageWidth: " + stage.stageWidth + " stageHeight: " + stage.stageHeight);
// clip always repositionned to the top left of the stage
clipAlways_TOP_LEFT.x = 0;
clipAlways_TOP_LEFT.y = 0;
// clip always repositionned to the bottom right of the stage
clipAlways_BOTTOM_RIGHT.x = stage.stageWidth - clipAlways_BOTTOM_RIGHT.width;
clipAlways_BOTTOM_RIGHT.y = stage.stageHeight - clipAlways_BOTTOM_RIGHT.height;
// clip always center (horizontal & vertical) of the stage
clipAlways_CENTER.x = (stage.stageWidth - clipAlways_CENTER.width)*0.5;
clipAlways_CENTER.y = (stage.stageHeight - clipAlways_CENTER.height)*0.5;
// clip with 80% width of the stage width
clipAlways_80p_WIDTH.width = stage.stageWidth*0.8;
// clip with a fixed large, may be cropped
clip_FIXED_WIDTH.with = 1000;
}
If you are publishing for mobile device, you may be interested by the screenDPI (flash.system.Capabilities.screenDPI).
See this post : How to resize clip in millimeters or inches ?
