7 Replies Latest reply on Oct 12, 2006 12:48 PM by S4Potential

    stage width

      is there any way how to get the stage _width value of an external .swf file using AS?
        • 1. Re: stage width
          Level 7
          If you are loading it into a parent swf you can use:
          Flash Player 4 as a read-only property.

          Property; the width of the movie clip, in pixels.

          The following code example displays the height and width of a movie clip in
          the Output panel:

          this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
          var image_mcl:MovieClipLoader = new MovieClipLoader();
          var mclListener:Object = new Object();
          mclListener.onLoadInit = function(target_mc:MovieClip) {
          trace(target_mc._name+" = "+target_mc._width+" X "+target_mc._height+"
          image_mcl.loadClip(" http://www.macromedia.com/devnet/mx/blueprint/articles/nielsen/spotlight_jnielsen.jpg",
          See also
          -- Dan Mode --> Adobe Community Expert*Flash Helps*
          http://www.smithmediafusion.com/blog/?cat=11*THE online Radio*
          http://www.tornadostream.com*Must Read*
          <webforumsuser@macromedia.com> wrote in message
          > is there any way how to get the stage _width value of an external .swf
          > file using AS?

          • 2. Re: stage width
            S4Potential Level 1
            The Stage size is the same for all loaded SWF and is _level0.

            If you have a movieclip within a movieclip and they both have different size, it doesn't affect the stage size because a loded SWF adopt the Stage propeties of _level0.

            The same goes if you have a swf loaded in a different level. It is the same as for the frame rate. The stage at authoring time determines the Stage properties for all loaded SWF

            You can get Stage property using the Stage class:

            On top of it, they are read only. They cannot be modified at runtime.

            Check help on the topic.

            Now if what you want to know is the size of the loaded SWF, it must be loaded into a movieclip. Only then you can figure out its size as explained by Dan.
            • 3. Re: stage width
              gringito Level 1
              yes, I load it into a parent movie.
              but MovieClip._width does not work for me.
              because there may be some objects beyond the main scene and if I ask for the MovieClip._width value I get the _width of all what is there.
              example: the external movie stage is 200x200 px, but there are masked objects 300x500pc size. If I ask for MovieClip._width I get 300px not 200px.
              thats why I search for stage.width value ...
              • 4. Re: stage width
                S4Potential Level 1
                Looks like you're targeting the worng movieclip._width

                When you load a SWF into a movieclip, ALL the content of that movieclip is replaced by the SWF. Therefore, when you ask for movieclip._width, you get the width of the loaded SWF.

                Now if that SWF has a bunch of objects beyond its stage area then you'll get the overall size. One way to work around this is to use a movieclip as your mask and check for the size of the mask instance name.


                You could also use a dynamic mask. The width is obtain the same way, via the instance name.

                Did I get your situation correctly? If not, post your FLA.
                • 5. Re: stage width
                  gringito Level 1
                  thank you. but I did not get it completely ...

                  I have a movie. I load external .swf into it, but I can not modify this file. Its done by other guys.
                  I want to align (CENTER/MIDDLE) the external .swf in my "loader" MC which is on the scene and has 745x100px fixed

                  this is my AS:

                  var mcLoader:MovieClipLoader = new MovieClipLoader();
                  var listener:Object = new Object();

                  listener.onLoadInit = function(target:MovieClip):Void {
                  target._x = (745 - target._width)/2;
                  target._y = (100 - target._height)/2;
                  mcLoader.loadClip("myswf.swf", "loader");

                  but if I ask for target._width I dont get the external .swf width. I get overall size of everything so the alignment does not work ... so I thought I have to get the .swf stage width value to get alignment working ...

                  • 6. Re: stage width
                    Rothrock Level 5
                    There is no property to tell you what size the original SWF was exported at.
                    • 7. Re: stage width
                      S4Potential Level 1
                      In an above post you said the SWF has a masked area.

                      Well, if you don't have access to the FLA of the SWF you're loading or if noone can tell you about its mask instance name, if any, then you're screwed.

                      The only way you can find the center of its viewable area is by trial and error and once you found it, you're at the mercy of is owner because every time he'll modify its content you may, and mostlikely will, end up with a different center.

                      Good luck.