Reputation: 153
How can I get the query string value from a browser sting into my flash movie?
For example, the link is www.blah.com/index.html?name=John
. The html page loads a flash movie, and I would like the flash movie to be able to access the variable name=John
.
Is this possible?
Upvotes: 2
Views: 919
Reputation: 13529
I'll suggest to read the variables via javascript or some server side language like PHP and send them to the swf like that:
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
);
}
"yourflashfile.swf?variable1=" + getURLParameter("parameter1") + "&variabl2=" + getURLParameter("parameter2")
Then in ActionScript use:
var variable1:String = loaderInfo.parameters.variable1 || "";
Upvotes: 0
Reputation: 11
Assuming ActionScript 3.
Checkout:Get current url to Flash swf using an External Interface call (circle cube).
Pretty much it seems to be: ExternalInterface.call(“window.location.href.toString”);
Then I guess you can get what you need by finding from the string.
Or you can use FlashVars and pass what you need to:http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html
In the embed tag it's: FlashVars="one=1&two=2"
and param: <param name="FlashVars" value="one=1&two=2" />
Upvotes: 1