3 Replies Latest reply on Apr 17, 2007 12:17 PM by MotionMaker

    MovieClipLoader height and width

    phil ashby Level 1
      Hi all,

      ok, situation is this...user clicks and drags a rectangle on the stage which gets created into a Loader which they can then load an image/swf into using filereference upload.

      Depending on the size and position of the rectangle the user has drawn, will depend on the size of the movieclip, as a resizer handler works out the scale of the object loaded and resizes it in proportion. This works fine if it's something like a jpg however, not with a swf. The problem is that when loading a swf in it only looks at the size of the movie IN THE FIRST FRAME! So _height and _width are incorrect when the swf is loaded in.

      For example, create a 50x50 box in the top left of a 550x400 stagesize flashmovie and tween it over a few frame to the bottom left and save and publish the movie. Now in a new movie create a moviecliploader and load in your tween movie and set a onloadinit listener to output the _width and _height. it will say 51 and 51 (not sure why the additional pixel) NOT 550x400.

      As such, the entire scaling and any subsequent resizing the user can do doesn't work properly. In this example, it would resize the 51 x 51 movie to proportional fill the 550x400 space, so you'd end up with a 400x400 square that will tween off the screen, as it's actually resized it to 4400 x 3200 !

      The only way I can find of getting round it is to put an 0 alpha moveclip the size of the stage on the clip to be loaded...which seem a bit of a hack.

      Any idea how I can get round this with AS?

        • 1. Re: MovieClipLoader height and width
          MotionMaker Level 1
          The size of a MovieClip depends on the size of the frame playing plain and simple.

          You can dynamically generate a movieclip on the first frame of the external swf once loaded and use the drawing API to draw a 0 alpha rectangle based on the dimensions the user created beforehand. In MovieClipLoader you would do this MovieClipLoader.onLoadInit method.

          However you still have the problem if the size of the first frame is larger than what the user specified.
          • 2. Re: MovieClipLoader height and width
            phil ashby Level 1
            Thanks MM, but if that is the case, how does the Flash Player application know to size itself to the original stage size. So in my example you double click a local swf file and windows opens the flash player app and the player sizes itself to 540x400 and NOT 50x50?

            It must store the original stage size somewhere in the swf for flashplayer to know it?! The player will also default to the orginal stagesize even if there is offstage content on the first frame....

            Hmmmm.....still confused
            • 3. Re: MovieClipLoader height and width
              MotionMaker Level 1
              Those numbers are the Stage.width and Stage.height. In the IDE that is Menu Modify->Document.

              Only the first loaded swf Stage height and Stage width survives. The first loaded swf becomes a mask for any other external swf loaded into it.

              When you load an external swf into a Movieclip, the external swf is loaded but its Stage data is lost and it only loads what is compatible inside a MovieClip.

              MovieClips have a dynamic changing _height and _width property depending on the frame and the object positions on that frame.

              If you need a first frame that is always a certain size, then include a rectangle MovieClip with an alpha = 0 on the first frame. If all frames, extend to all frames but remember any objects that move beyond that change _width and _height..