This is what I used to pass a GET query string into my AS3.
First, here's the actions from the main timeline that gather the FlashVars from PHP (modified code from developphp.com):
// Claim the offset Number that spaces the text
// fields so they are not right on top of each other
var offSet:Number = 18;
// Claim keyStr variable as a string
var keyStr:String;
// Claim valueStr variable as a string
var valueStr:String;
// Create the paramObj Object and set it to load parameters
// from the root level being sent in by FlashVars externally
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
// Set Text Format Object, its attributes and values
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.size = 15;
// Create the loop that iterates over all of the variables you send in using FlashVars
var i=0;
for (keyStr in paramObj) {
i++;
valueStr = String(paramObj[keyStr]); // This line gets the values of each variable sent in
var myText:TextField = new TextField(); // Create a text field to read and access each var
myText.defaultTextFormat = format; // Set the formatting into the text field properties
myText.text = keyStr + " value is: " + valueStr; // Use the vars here, I place into text field waiting
myText.y = offSet*i; // Before we place each text field on stage we offSet it
myText.width = 380; // Set the width of the text field
this.addChild(myText); // Now this line actually places the text field on stage
}
Then here's the PHP (also modified from developphp.com)
<?php
$vars = http_build_query($_GET);
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Editor</title>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
</head>
<body bgcolor="#333333">
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '400',
'height', '400',
'src', 'editor',
'FlashVars', '<?php echo $vars; ?>',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'editor',
'bgcolor', '#ffffff',
'name', 'editor',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', 'editor',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="400" height="400" id="AS3_php_Var_into_flash" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="editor.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="FlashVars" value="<?php echo $vars; ?>" />
<embed src="editor.swf" FlashVars="<?php echo $vars; ?>" quality="high" bgcolor="#ffffff" width="400" height="400" name="editor" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</noscript>
</body>
</html>
http_build_query($_GET) is a handy way to convert the URL query string back into a query string for Flash's use.
I prefer this method because it doesn't require any hacks or importing of classes to accomplish this simple task.