如何调整外部SWF以适应集装箱?集装箱、以适应、SWF

由网友(你眼里有星星)分享简介:我想做到的是,使之适合的显示对象是psented在舞台上的容器$ P $来调整外部SWF。对于现在出现的容器外。重要提示:我不希望外部SWF占据了整个舞台;我有一个特殊的地方(即容器),它在舞台上。解决方案 公共职能loaderComplete(事件:事件):无效{VAR内容:影片剪辑=影片剪辑(event.cur...

我想做到的是,使之适合的显示对象是psented在舞台上的容器$ P $来调整外部SWF。对于现在出现的容器外。

重要提示:我不希望外部SWF占据了整个舞台;我有一个特殊的地方(即容器),它在舞台上。

解决方案

 公共职能loaderComplete(事件:事件):无效
  {
      VAR内容:影片剪辑=影片剪辑(event.currentTarget.content);

      //外部SWF的尺寸
      VAR _width:INT = content.width;
      VAR _height:INT = content.height;

      //你有几个选择这里,假设你有一个容器雪碧
      //可以直接设置到您的容器的尺寸,如果有的话
      如果(container.width< _width)
          _width = container.width //并做相同的高度

      //或者你可以扩展你的内容,以适应,这里有一个简单的版本
      //但你可以检查高度过或继续检查两个值
      //直到它适合
      如果(container.width< _width)
      {
          VAR规模:数= container.width / _width;
          content.scaleX = content.scaleY =规模;
      }

      //当一切完成后,您可以将您的内容
      container.addChild(内容);
  }
 

您也可以检查greensock.com, http://www.greensock.com/ 他们有一个伟大的设置加载类,您可以指定宽度和放大器;要加载,设置一个容器将其加载到甚至指定您希望如何适应内容的内容的高度,为您节省一切code以上;)

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.

解决方案

  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 ;)

阅读全文

相关推荐

最新文章