Flash 从浏览器链接获取查询字符串
如何将浏览器中的查询字符串值输入到flash电影中 例如,链接是www.blah.com/index.html?name=John。html页面加载flash电影,我希望flash电影能够访问变量Flash 从浏览器链接获取查询字符串,flash,actionscript,Flash,Actionscript,如何将浏览器中的查询字符串值输入到flash电影中 例如,链接是www.blah.com/index.html?name=John。html页面加载flash电影,我希望flash电影能够访问变量name=John 这可能吗?假设ActionScript 3 结帐: 几乎是:ExternalInterface.call(“window.location.href.toString”) 那么我想你可以从字符串中找到你需要的东西 或者,您可以使用FlashVar并传递所需内容: 在嵌入标记中,它是:
name=John
这可能吗?假设ActionScript 3 结帐: 几乎是:
ExternalInterface.call(“window.location.href.toString”)代码>
那么我想你可以从字符串中找到你需要的东西
或者,您可以使用FlashVar并传递所需内容:
在嵌入标记中,它是:FlashVars=“one=1&two=2”
和param:
我建议通过javascript或一些服务器端语言(如PHP)读取变量,并将它们发送到swf,如下所示:
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
);
}
"yourflashfile.swf?variable1=" + getURLParameter("parameter1") + "&variabl2=" + getURLParameter("parameter2")
然后在ActionScript中使用:
var variable1:String = loaderInfo.parameters.variable1 || "";