2009-11-17 35 views
1

我用Loader加载了一个外部的swf文件,并尝试在一个固定的区域显示它,就像一个固定的尺寸精灵对象。而且我不知道swf文件的确切大小,我只是希望它适合固定区域。那可能吗?如何在Actionscript项目中更改外部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到适合面板的面积。我怎样才能做到这一点?

回答

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监听器。

+0

仍然没有工作,所以我怀疑,如果这是一个不可能的任务。 或者我们不能使用这种常规武器... – user198816 2009-11-18 01:11:44

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; 
} 
+1

我试过了,不行 – user198816 2009-11-18 01:09:51

相关问题