views:

22

answers:

1

What I want to accomplish is to resize an external SWF so that it fits into the display object that is presented as a container on the stage. For now it show up outside of the container.

Important: I do not want an external SWF to occupy the whole stage; I have a special place (that container) for it on the stage.

+1  A: 
  public function loaderComplete(event:Event):void
  { 
      var content:MovieClip = MovieClip(event.currentTarget.content );

      //the dimensions of the external SWF
      var _width:int = content.width;
      var _height:int = content.height;

      // you have several options here , assuming you have a container Sprite
      // you can directly set to the dimensions of your container, if any
      if( container.width < _width )
          _width = container.width // and do the same for height

      // or you could scale your content to fit , here's a simple version
      // but you can check the height too or keep checking both value
      // until it fits
      if( container.width < _width ) 
      { 
          var scale:Number = container.width / _width;
          content.scaleX = content.scaleY = scale;
      }

      // when all done, you can add your content
      container.addChild( content );
  }

You could also check greensock.com , http://www.greensock.com/ they have a great set of Loading classes where you can specify the width & height of the content you want to load , set a container to load it into and even specify how you'd like the content to fit, saves you all the code above ;)

PatrickS