Search code examples
flashactionscript-3actionscriptriarich-internet-application

Flash Resize Problem


I am building a Flash project which is intended to be a very visually appealing application. In order to accomplish this, I am hoping to make the application fit to 100% size of the browser window and fill its contents with visually appealing images and interactivity.

Some of these objects I would like to maintain a consistent distance from a particular side of the stage, say, the left side. Here is my code I am using to keep a logo 100px from the left side of the application during run-time and re-size:

import flash.events.Event;

var logo:Logo = new Logo();

stage.addEventListener(Event.RESIZE, resizeListener);

function resizeListener(e:Event):void {
  logo.x = 100;
}

logo.x = 100;
logo.y = stage.stageHeight / 2;
logo.width = logo.width / 2;
logo.height = logo.height / 2;

addChild(logo);

The problem with this is, for some reason, the logo stays in the spot, and doesn't maintain a consistent distance from the left side of the stage when the application is re-sized. Could someone help me revise the above code to keep the logo 100px from the left side?

Thank you for your help.


Solution

  • Make sure that you've set the stage's align and scaleMode.

    stage.align = StageAlign.TOP_LEFT;
    stage.scaleMode = StageScaleMode.NO_SCALE;
    

    Ideally you'd set this via the document class and there may be security issues if you try to make these changes from an imported MovieClip.

    Also, the flash debugging player may have issues with stage alignment and scale that do not appear in live browser tests.