0

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.

Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195

1 Answers1

3

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.

zzzzBov
  • 174,988
  • 54
  • 320
  • 367
  • ok, we're making progress, but I have a background image which has an issue with the TOP_LEFT setting. is there a way we could around that with the default StageAlign setting? – Oliver Spryn May 28 '11 at 01:28
  • 1
    You can try other values for the [StageAlign](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/StageAlign.html) property, but you may have to recalculate the position of the logo on resize (just a guess but `-stageWidth / 2` for center alignment) – zzzzBov May 28 '11 at 01:32
  • Ah... okay, I changed the StageAlign to left, and set the registration point of the background to the left, as well. Before, the background had the reg point at the center, and wouldn't be large enough to cover the stage when it was re-seized too large. So, now the background image fits well when the stage is re-sized. Thanks for your help! – Oliver Spryn May 28 '11 at 01:36