Skip to main content
Inspiring
June 3, 2009
Question

Dynamically changing the height and width of Stage

  • June 3, 2009
  • 1 reply
  • 1405 views

Hi,

          I would like to know how can I change the height and width of stage dynamically. I tried it with the following code:

                         Stage.height = 250;

                         Stage.width = 250;

during the run time. Initially the Stage is at a height and width of 370 and 450 respectively. Also when I tried to trace the height and width of Stage after resizing the stage width and height, its showing the old value of width and height. That means the width and height not chnaging. Anybody have any idea about this.

This topic has been closed for replies.

1 reply

RossRitchey
Inspiring
June 3, 2009

The Design-time and Run-time Stage are 2 completely different things.

At Design-time Adobe gives you a "Stage" that you can set the size of, and work with.  The initial opening size of the SWF is based on this size.  If you never display the SWF at any other size - the runtime stage is the same size as the design-time stage.

But: The runtime stage is always the currently displaying size of the SWF.  That means, if you want to change its size, you need to change the displaying size of the SWF object in the HTML.

The easiest way to do this is with a Javascript function (especially if you use SWFObject's dynamic embed method)

SreelashAuthor
Inspiring
June 3, 2009

Hi Ross,

Actually I am changing the height and width of a video player according to the value given at run time. When I open it in html, that change is reflecting, but the stage size will be with the older value, i.e.(450 by 370). Actually my need is to change the width and height of the stage according to the height and width given for the video player. when I open that video player in html, the size of swf component will be according to the size given for video player.

Regards,

Sreelash.S

RossRitchey
Inspiring
June 3, 2009

If I am understanding you correctly, you want to:

Dynamically load a video at runtime and reset the SWF object's size to match the video's size?  Correct?

You will want to look into the ExternalInterface Class, use SWFObject to Dynamically embed the SWF in the page, and write a Javascript function to resize the SWF Object at runtime.