5 Replies Latest reply on Jun 4, 2009 2:06 AM by Sreelash

    Dynamically changing the height and width of Stage

    Sreelash Level 1

      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.

        • 1. Re: Dynamically changing the height and width of Stage
          RossRitchey Level 4

          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)

          • 2. Re: Dynamically changing the height and width of Stage
            Sreelash Level 1

            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

            • 3. Re: Dynamically changing the height and width of Stage
              RossRitchey Level 4

              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.

              1 person found this helpful
              • 4. Re: Dynamically changing the height and width of Stage
                Sreelash Level 1

                 

                 

                Hi Ross,

                            I could understand something about the problem after making a research on this topic. We can't change the width and height of stage from actionscript itself, right? I will explain the way I am planning to do. I don't know whether its right or not. Anyway you just go through it. First the player need to be resized, according to the specified height and width. Then in the object tag, there are two fields named height and width. We should change these value according to the specified height and width of video controller, dynamically. Am I right? But I am confused with two properties of Stage such as: align and scaleMode. The code was actually developed my trainer. There, the scaleMode is set to "noScale" and no align property is used. My doubt is how should I set align and scaleMode properties of Stage. Hope you understood what I meant.

                 

                Regards,

                      Sreelash.S.

                • 5. Re: Dynamically changing the height and width of Stage
                  Sreelash Level 1

                  Hi Ross,

                            I could understand something about the problem after making a research on this topic. We can't change the width and height of stage from actionscript itself, right? I will explain the way I am planning to do. I don't know whether its right or not. Anyway you just go through it. First the player need to be resized, according to the specified height and width. Then in the object tag, there are two fields named height and width. We should change these value according to the specified height and width of video controller, dynamically. Am I right? But I am confused with two properties of Stage such as: align and scaleMode. The code was actually developed my trainer. There, the scaleMode is set to "noScale" and no align property is used. My doubt is how should I set align and scaleMode properties of Stage. Hope you understood what I meant.

                   

                  Regards,

                       Sreelash.S.