3 Replies Latest reply on Sep 28, 2006 7:35 AM by Newsgroup_User

    Detect window size and resize like www.tronicstudio.com

    brucio981
      Hi all is there any actionscript's guru able to help me?
      What I need is simply a script to detect the window size and resize the swf file according to the screen resolution.
      Here an easy and clear example of what I'm looking for: www.tronicstudio.com Text
      Thanks all
        • 1. Re: Detect window size and resize like www.tronicstudio.com
          Level 7
          brucio981,

          > What I need is simply a script to detect the window
          > size and resize the swf file according to the screen
          > resolution.

          ActionScript doesn't provide a way to resize the Stage. SWFs are either
          set to a specific pixel width and height in the HTML, or they may be set to
          a percent (e.g. 100%), which causes the SWF to fill its container.

          > Here an easy and clear example of what I'm looking for:
          > www.tronicstudio.com Text

          That website uses JavaScript to open a new window to the available
          screen dimensions. In fact, you can view the HTML source in the first
          document (not the pop-up) to see how it's done. Look for references to the
          JavaScript openSite() function, which is defined in this file ...

          http://www.tronicstudio.com/media/script/common.js


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Detect window size and resize like www.tronicstudio.com
            Level 7
            Hi there
            You still can do this by actionscript too
            let us say you have a swf that will open in a fullscreen mode and you want
            to know if the user monitor resolution is 800 x 600 or 1024x768 so you need
            to do the following
            - get the resolution the user using
            - condition to do some code if the resolution

            //// Here is the code you need //////
            function getResolution() {
            var xPixels:Number = System.capabilities.screenResolutionX;
            var yPixels:Number = System.capabilities.screenResolutionY;
            //trace("System Resolution = "+xPixels+"x"+yPixels);
            if (xPixels<=800) {
            //do something here
            } else if (xPixels>=1024) {
            //do another thing here
            }
            }
            // call the function
            getResolution();


            * I hope it helped you

            "David Stiller" <stiller-NO-SPAM-@quip.net> wrote in message
            news:efblc8$155$1@forums.macromedia.com...
            > brucio981,
            >
            >> What I need is simply a script to detect the window
            >> size and resize the swf file according to the screen
            >> resolution.
            >
            > ActionScript doesn't provide a way to resize the Stage. SWFs are
            > either set to a specific pixel width and height in the HTML, or they may
            > be set to a percent (e.g. 100%), which causes the SWF to fill its
            > container.
            >
            >> Here an easy and clear example of what I'm looking for:
            >> www.tronicstudio.com Text
            >
            > That website uses JavaScript to open a new window to the available
            > screen dimensions. In fact, you can view the HTML source in the first
            > document (not the pop-up) to see how it's done. Look for references to
            > the JavaScript openSite() function, which is defined in this file ...
            >
            > http://www.tronicstudio.com/media/script/common.js
            >
            >
            > David Stiller
            > Adobe Community Expert
            > Dev blog, http://www.quip.net/blog/
            > "Luck is the residue of good design."
            >
            >


            • 3. Re: Detect window size and resize like www.tronicstudio.com
              Level 7
              Essam,

              > You still can do this by actionscript too

              Unfortunately, ActionScript cannot resize the SWF or the window it's in.

              > let us say you have a swf that will open in a fullscreen mode

              The original question was "to detect the window size and resize the swf
              file according to the screen resolution," which is a teensy bit muddy. The
              window may not be full screen, of course. Even if the browser is full
              screen, the SWF likely won't be, because of things like the browser title
              bar, toolbars, etc.

              System.capabilities is a terrific resource, though, for sure.


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."