2012-12-19 36 views
2

當我加載它Loader.load我可以通過URLRequest傳遞它們。但在Loader.loadBytes的情況下我沒有看到任何機會。 此問題與Passing flashvars-style parameters to a loaded SWF類似。如何將FlashVars傳遞給由Loader.loadBytes加載的swf?

+0

您是否必須使用FlashVars?爲什麼不只是讓它實現一個接口並調用一個方法或其他東西呢? –

+0

是的,我有。我沒有訪問加載的瑞士法郎。 – user1826684

+0

爲什麼不呢?整個事件觸發後,loaderInfo.content是否爲空? –

回答

2

答案在API文檔中。我被暗示在另一個網站。

您應該使用parameters屬性LoaderContext對象,您將其傳遞給Loader.loadBytes方法。但它僅適用於AS3 swfs。對於AS1/2的swfs似乎是不可信的。

var swf:ByteArray = getSWF();//swf bytes from nowhere 
var loader:Loader = new Loader() 
var loaderContext:LoaderContext = new LoaderContext(); 
loaderContext.parameters = {a: "1", b: "2"}; 
loader.loadBytes(swf, loaderContext); 

我認爲現在是正確的答案。

0

太棒了!只有在參數爲字符串時纔會運行:

loaderContext.parameters = {"a": "1", "b": "2"};