I don't know if its the right way to call this problem but pls bear with me.
http://mydomain.com/trackUser.php?userId=001
I want to get the variables included in the url above to be used in my flash project.
I have a code in my flash that determines if the user is a male or female and output back the same url but with additional variables on it.
http://mydomain.com/trackUser.php?userId=001&score=9
Any reply is much appreciated.
Here are a few approaches to getting the query string data...
AS3 Get URL Variables
---------------------
http://mikethenderson.com/2009/02/as3-return-query-string-value-versio n-2/#more-105
OR
In your HTML:
var flashvars = {};
if (swfobject.getQueryParamValue("chosenCLIP")) {
flashvars.clip = swfobject.getQueryParamValue("chosenCLIP");
}
swfobject.embedSWF("myMovie.swf", "myContent", "550", "400", "9.0.0", "", flashvars);
And the clip variable will be available as a FlashVar to your movie:
var theClip = loaderInfo.parameters.clip;
OR
In the swf... Try:
ExternalInterface.call("window.location.href.toString");
and parse the string
Hi sir Ned,
Thanks for the reply.
I already done this in AS2 code here it is:
// code for trackUserL.php
if (!$_REQUEST[userId]) exit;
if ($_REQUEST[rprod]==1) {
mysql_query("update tblproduct set loaded=NOW() where viewed<>1 and prodId='$_REQUEST[userId]'");
}
else {
mysql_query("update tbluser set loaded=NOW() where viewed<>1 and userId='$_REQUEST[userId]'");
}
// end for trackUserL.php
// code for trackUser.php
if (!$_REQUEST[userId]) exit;
if ($_REQUEST[rprod]==1) {
mysql_query("update tblproduct set End=NOW() where viewed<>1 and prodId='$_REQUEST[userId]'");
}
else {
mysql_query("update tbluser set viewedDateEnd=NOW() where viewed<>1 and userId='$_REQUEST[userId]'");
}
// end for trackUser.php
_root.createEmptyMovieClip("tmp",900);
_root.createEmptyMovieClip("tmpLoded",101);
_root.interval = setInterval(_root.logger,5000);
loadVariables("http://www.domain.com/trackUserL.php?userId="+_root.userId+"&rprod="+_root.rprod+"&str="+_root.generateRandomStr() ,_root.tmpLoded);
function logger () {
loadVariables("http://www.domain.com/trackUser.php?userId="+_root.userId+"&str="+_root.generateRandomStr(),_root.tmp);
}
function generateRandomStr () {
var dt = new Date();
var str = dt.getMilliseconds()+""+dt.getSeconds()+""+dt.getMinutes()+""+dt.getH ours()+""+dt.getDate()+""+dt.getMonth()+""+dt.getFullYear();
return str;
}
I have a hard time converting this code to get it to work in AS3.
I googled something like flashvars by using URLRequest, URLLoader, URLVariables but I didn't notice how to access the variables loaded from the url.
I want to load a php file (trackUserL.php) that query a "userId" and "prodId" in the database and use it on my flash to determine if the user is a registered member and what product he is viewing.
After which I'll pass the loaded userId from trackUserL.php to another php file trackUser.php under function logger that updates the database every 5 seconds.
I know its confusing cause in my first post I thought it is a querystring but It is accessing variables that is fetched by php from the database.
Hi,
Im going to go with what Ned said about using
ExternalInterface.call("window.location.href.toString");
so the above will pull somthing like this in as a string...
http://www.aidanmack.co.uk/?var1=goo
Then im going to use split to split the string on the =
and that will give me the datas im after!...
Just seems a bit crude?...
No built in class or anything we can use in flash?
meh it does what i want it to do anyway!
North America
Europe, Middle East and Africa
Asia Pacific