如何更改Actionscript项目中的外部swf维度?

时间:2009-11-17 11:59:33

标签: actionscript flash dimension

我使用Loader加载外部swf文件,并尝试将其显示在固定区域,如固定维度sprite对象。我不知道swf文件的确切大小,我只是想让它适合固定区域。这可能吗?

代码:

var loader:Loader = new Loader();
loader.load(new URLRequest("some path"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(e:Event):void
{
    var loaderinfo:LoaderInfo = event.target as LoaderInfo;
    loaderinfo.content.width = 300;
    loaderinfo.content.height = 300;
    loaderinfo.content.x = 0;
    loaderinfo.content.y = 0;//note that this works for displaying picture, but not for swf
    thePanel.stage.addChild(loader);
}

我希望swf适合面板的区域。我怎么能这样做?

2 个答案:

答案 0 :(得分:0)

而不是loaderInfo.content.height尝试loaderInfo.loader.height

如果这仍然不适合您,请尝试以下方法:

var container:Sprite = new Sprite();
container.addChlid(loaderInfo.loader);
container.width = 300;
container.height = 300;
thePanel.addChild(container)

...在您的Event.COMPLETE侦听器中。

答案 1 :(得分:0)

addChild(loader); //you can add it, as it is kind of proxy display object container
function completeHandler(e:Event):void { 
  loader.width = 300; 
  loader.height = 300; 
  loader.x = 0; 
  loader.y = 0;
}