3 Replies Latest reply on May 3, 2010 12:55 PM by kglad

    Scaling SWF to less than or equal to original size

    atrzebunia Level 1

      Does anyone know how to scale a SWF in the browser window, but not larger than the original stage size in the FLA file?  For instance, I've designed a course in Flash with stage size of 1024x768 in Flash.  In the published HTML document, I change the following values:

       

      'width', '1024' changed to 'width', '100%'

      'height', '768' changed to 'height', '100%'

      'scale', 'noscale' changed to 'scale', '100%'

       

      These changes in the HTML source code allow the SWF to size with the browser, but I don't want the SWF to grow larger than 1024x768 if the browser window is greater than these dimensions.  I want the max size of the SWF to be 1024x768 regardless of the browser window.

       

      Does anyone know how to achieve this in the HTML source code and/or AS2?

       

      Thank you!

        • 1. Re: Scaling SWF to less than or equal to original size
          kglad Adobe Community Professional & MVP

          use a stage onresize listener to control the size of your flash display

          • 2. Re: Scaling SWF to less than or equal to original size
            atrzebunia Level 1

            In addition to my original post, I took the advice to use the onResize listener, but am running into several issues described below the following code:

             

            Stage.align = "TL"; //doesn't work; why?
            Stage.scaleMode = "noScale";
            var stageListener:Object = new Object();
            stageListener.onResize = function():Void
            {
                if(Stage.width < 1024.0 || Stage.height < 768.0)
                {
                    trace("The movie should be scaling");
                    Stage.scaleMode = "scale";
                }
                else
                {
                    trace("The movie should not be scaling");
                    Stage.scaleMode = "noScale"; //doesn't work; why?
                }
            }
            Stage.addListener(stageListener);

             

            The above code works partially, but then stops, i.e. when I press CTRL + ENT to test the SWF:

            1. The first line of code does not recognize that I want to top-center the SWF.
            2. If I resize the SWF I get the correct messages traced initially, but the SWF continues to scale if the stage is > 1024x768.
            3. What should my HTML publish settings in Flash be for this code to work properly?  Should this code override the HTML publish settings?  If so, it doesn't.  In other words, the SWF doesn't scale at all when launched in the published HTML file, but the stand-alone SWF file does scale.  I would have to modify the HTML source code for the SWF to scale, so it seems that there is a disconnect between the AS2 code and the published HTML file.

             

            Thanks for any help you can offer.

            • 3. Re: Scaling SWF to less than or equal to original size
              kglad Adobe Community Professional & MVP

              click file/publish settings/html and select percent, 100 x 100.  retest.