Programmatically Setting Stage Width/height

how do i programatically adjust the height and width of the stage in Flash CS3 using actionscript ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

if you're running in a browser you need to put the SWFinside a container (eg <div>), set the embed size to 100% width/height and then resize the DIV (using javascript) to change the stage size.

You will need to set the stage scale mode to 'no scale' as follows:


import flash.display.StageScaleMode;
import flash.display.StageAlign;
stage.scaleMode = StageScaleMode.NO_SCALE; //set noscale
stage.align = StageAlign.TOP_LEFT;         //optionally set the alignment of the content inside the SWF

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
whatisittellmeAuthor Commented:
i think you got my question wrong. or may be i dint put it correctly.
when i press ctrl+enter on my .fla file, swf file plays. i want to adjust the size of the output swf programatically.
(usually, by varying number of pixels in properties window of document class, i will be able to change the width and height of the output swf. but i am not sure how to achieve this via actionscipt3.)

What's the end publish format? Are you trying to make a projector or something that you will eventually run in a web page?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

whatisittellmeAuthor Commented:
i will be running it in a webpage eventually.
You're best off using the method I posted earlier in that case. You'll need to manually resize (drag) the container if you're testing inside the authoring environment as there's no way to programatically set that.

At runtime, use javascript to resize the DIV containing the swf.
whatisittellmeAuthor Commented:
thank you, that helps.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.