如何從瀏覽器中獲取查詢字符串值來刺入我的Flash影片?從瀏覽器鏈接獲取查詢字符串
例如,鏈接是www.blah.com/index.html?name=John
。這個html頁面加載了一個flash影片,我希望flash影片能夠訪問變量name=John
。
這可能嗎?
如何從瀏覽器中獲取查詢字符串值來刺入我的Flash影片?從瀏覽器鏈接獲取查詢字符串
例如,鏈接是www.blah.com/index.html?name=John
。這個html頁面加載了一個flash影片,我希望flash影片能夠訪問變量name=John
。
這可能嗎?
假定ActionScript 3中
結帳:Get current url to Flash swf using an External Interface call (circle cube)。
幾乎是它似乎是:ExternalInterface.call(「window.location.href.toString」);
那我猜你可以得到你需要從字符串尋找什麼。
或者,您可使用Flash變數,並通過你所需要的:http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html
在嵌入標籤是:FlashVars="one=1&two=2"
和param:<param name="FlashVars" value="one=1&two=2" />
我會建議通過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 || "";