Rob*_*bin 7 flashvars actionscript-3
我有一个A.swf,它将B.swf加载到一个movieclip上,需要传递一些FlashVars.使用html加载B.swf时,我可以正常传递FlashVars.当从A.swf传递时,它得到一个
错误#2044:未处理的ioError:text =错误#2032:流错误.网址:文件:
A.swf中的代码是
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);
Run Code Online (Sandbox Code Playgroud)
在B.swf中,它正在检查Flashvars.从HTML方面它工作正常
this.loaderInfo.parameters.xml
Run Code Online (Sandbox Code Playgroud)
Sea*_*ara 17
尽管查询字符串方法在本地工作正常,但如果您使用的是Flash Player 10.2,则会有一个新的API.
var context:LoaderContext = new LoaderContext();
context.parameters = {'xml': 'test.xml'};
loader.load(request, context);
Run Code Online (Sandbox Code Playgroud)
文档在这里:http: //help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/LoaderContext.html#parameters
您可以在加载时将 flash 变量添加到 URI 中
URLRequest(String("B.swf" + "?myvar=45"));
Run Code Online (Sandbox Code Playgroud)
问题是当你加载 uri 中的字符串时,它被放入一个对象中loaderInfo.parameters,因此如果您想传递这些参数,则需要创建一个字符串来将这些参数传递到其中。
这是来自http://ragona.com/blog/pass-flashvars-loaded-swf/的脚本,它展示了如何将其再次转换为字符串数组
//:: Store loader info
var lInfo:Object = this.root.loaderInfo.parameters;
//:: Flashvars
var fVars:String = "?whee=nada"; //:: Getting the syntax change (? --> &) out of the way with a dummy var
//:: Set path + data
for (var flashVar in lInfo)
{
fVars += "&" + flashVar + "=" + lInfo[flashVar];
}
var myRequest:URLRequest = new URLRequest(String("/myPath.swf" + fVars));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19829 次 |
| 最近记录: |