views:

2986

answers:

4

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;
A: 

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?

Luke
No, it only resizes the stage and not the objects on the stage.
pypmannetjies
+3  A: 

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...

Scott Evernden
Ahh... but it is not in a website. But it's ok, I've found that you can make everything on the stage into a new movieclip, resize that and then just break the movieclip apart again.
pypmannetjies
A: 

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

+1  A: 

It's more or less the HTML wrapper you have to change. This in deed needs JavaScript. I wrote an AS3 class with already contains the JavaScript so you don't need an extra js:

http://blog.sebastian-martens.de/2010/06/resize-flash-application-container/

Hope this helps.

sebastian
interesting, thanks
pypmannetjies