I would like to pass a variable from php to an embedded swf without a user seeing the variable.
I have successfully passed a variable from a seperate php fle into my swf but I had to use an external php file to do it.
file.php:
<?php
$myData = "foo";
echo "&swf_Var = $myVar";
?>
AS2 first frame:
stop();
myData = new LoadVars();
myData.load("http://www.mysite.com/php/file.php");
myData.onLoad = function(success)
{
if(success)
{
passed_var = myData.swf_Var;
trace(passed_var); // just some testing
gotoAndStop(2); //go to my content
trace("worked");
}else{
trace("Didn't work");
}
}
When I attempt this method in the same page I embed the swf, it prints it to the browser (not good).
I want users to be able to see my swf but if they try to access it directly it will load but not do anything because the variable is required for it to do anything
like
if (!=myvar){
gotoAndStop("sorry");
}else{
gotoAndStop("content");
}
The other alternative I am trying is to use a php file to load the swf like this
index.php
<embed
src="http://www.mysite.com/load_swf.php"
width="400"
height="300"
/>
load_swf.php
<?php
header("Location: http://www.mysite.com/swf/preloader.swf");
header( "content-type: application/x-shockwave-flash" );
exit;
?>
I would like to use the second method because then where my swf is located isn’t ever shown to the user. However, this one isn’t working either.
Any help with either method will be appreciated.