Resize Window Using ActionScript 3.0

Can I resize an entire Flash project using ActionScript or some other method?

I created the Flash CS3 application 1024x768, but upon closer inspection of the specifications, I now understand that it should be 800x600. Instead of manually making it smaller, I would like to resize the window as if someone were dragging the outer edge. Or maybe add a button that allows you to switch between 1024x768 and 800x600. Is it possible?

I mean something like this:

stage.stageWidth = 800; stage.stageHeight = 600; 
+6
actionscript flash resize window
source share
4 answers

Yes stageWidth and stageHeight are readonly, despite the docs. But if the SWF is embedded in the web page, then changing its width and height of the element will change the size of the scene, and scaleMode will determine how it is processed. All SWFs on my Enjoy3D website do this when resizing the window ...

+4
source share

If you would like, you could just edit the HTML wrapper for your SWF and say whether there will be new sizes, although I'm afraid the rasterized media will be pixelated even when compressed. It’s best to cut everything, even if you don’t want to.

If you just need to do this in Flash, use the ExternalInterface class of the flash.external package to make a JavaScript function call in your HTML. Make sure your swf is inside the div and set to 100% of the height and width of the div. Now you just resize the div via JavaScript via ActionScript.

Make sure you have stage.scaleMode installed the way you want.

Greetings

+1
source share

You cannot change the width and height of a scene from ActionScript, these properties are read-only.

Could you just set the size of the scene properties (suppose you're using Flash here) to 800 by 600 before compiling SWF?

0
source share
  • You can set the width and height properties in the xxx-app.xml file
  • If you want to do this dynamically, you can use the FlexGlobals.topLevelApplication.width and height properties or the deprecated Application.application.width and height properties
  • Or, if you have a clean ActionScript project in which you cannot run FlexGlobals or Application, you can do the following from your main actionscript (Sprite) file (note that the step must be initialized before)

     width = WIDTH; height = HEIGHT; stage.stageWidth = WIDTH; stage.stageHeight = HEIGHT; stage.nativeWindow.width = WIDTH; stage.nativeWindow.height = HEIGHT; 
0
source share

All Articles