我想要完成的是调整外部 SWF 的大小,使其适合在舞台上作为容器呈现的显示对象。现在它显示在容器外部。
重要提示:我不希望外部 SWF 占据整个舞台;我在舞台上为它准备了一个特殊的地方(那个容器)。
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 );
}
您还可以查看 greensock.com ,http://www.greensock.com/ http://www.greensock.com/他们有一组很棒的加载类,您可以在其中指定要加载的内容的宽度和高度,设置要加载的容器,甚至指定您希望内容如何适合,为您节省上面的所有代码;)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)