Question

Is there any way to resize an entire Flash project using Actionscript or some other method?

I have created a 1024x768 Flash CS3 application, but upon closer inspection of the specifications, I now realise it has to be 800x600. Instead of manually making everything smaller, I'd like to resize the window as if someone were dragging the outside edge. Or perhaps add a button that allows switching between 1024x768 and 800x600. Is this possible?

I mean something like this:

stage.stageWidth = 800;
stage.stageHeight = 600;
Was it helpful?

Solution

Yes stageWidth and stageHeight are readonly, despite the docs. But if the SWF is embedded in a web page, then changing its element width and height will change the stage size and scaleMode will determine how that is handled. All the SWFs at my Enjoy3D web site do this on window resize...

OTHER TIPS

If you wanted you could merely edit the HTML wrapper for your SWF and tell if the new dimensions, though I fear and rasterized media will be pixelated even when shrinking. It is best to shrink everything, even though you don't want to.

If you just really need to do it in flash use the ExternalInterface class of the flash.external package to make a call to a JavaScript function in your HTML. Make sure your swf is inside a div and set to 100% of the div's height and width. Now you merely change the size of the div via JavaScript via Actionscript.

Make sure that you have stage.scaleMode set the way you want it.

Cheers

You can't change the stage width and height from Actionscript, those properties are read-only.

Couldn't you just set the size of the stage properties (I assume you're using Flash here) to 800 by 600 before you compile your swf?

  1. You could set the width and height properties in your xxx-app.xml file
  2. If you want to do it dynamically, you could use FlexGlobals.topLevelApplication.width and height properties or the deprecated Application.application.width and height properties
  3. Or if you have a pure ActionScript project, whereby you cannot do FlexGlobals or Application, you could from your main actionscript file (Sprite) execute the following (note that stage must be initialised before doing this)

    width = WIDTH;
    height = HEIGHT;
    stage.stageWidth = WIDTH;
    stage.stageHeight = HEIGHT;
    stage.nativeWindow.width = WIDTH;
    stage.nativeWindow.height = HEIGHT;
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top