2009-11-17 39 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

相關問題