AS3 将 FlashVars 传递给加载的 swf [英] AS3 Pass FlashVars to loaded swf
问题描述
我有一个 A.swf,它将 B.swf 加载到影片剪辑上,并需要向它传递一些 FlashVars.使用 html 加载 B.swf 时,我可以很好地传递 FlashVars.当从 A.swf 传递时,它得到一个
I have a A.swf which loads B.swf onto a movieclip and needs to pass it some FlashVars. When loading B.swf with html, I can pass FlashVars fine. When passing from A.swf, it gets a
错误 #2044:未处理的 ioError:.文本=错误 #2032:流错误.网址:文件:
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: file:
A.swf 中的代码是
The code in A.swf is
var request:URLRequest = new URLRequest ("B.swf");
var variables : URLVariables = new URLVariables();
variables.xml = "test.xml";
// This line causes the error 2044, else B.swf loads fine with FlashVars
request.data = variables;
loader.load (request);
在 B.swf 中,它像这样检查 Flashvars.它从 html 端工作正常
In B.swf, it is checking the Flashvars like so. It works fine from html side
this.loaderInfo.parameters.xml
推荐答案
虽然 querystring 方法应该可以在本地正常工作,但如果您使用的是 Flash Player 10.2,则有一个新的 API.
Although the querystring method should work fine locally, if you're using Flash Player 10.2, there's a new API for this.
var context:LoaderContext = new LoaderContext();
context.parameters = {'xml': 'test.xml'};
loader.load(request, context);
这篇关于AS3 将 FlashVars 传递给加载的 swf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!