から撮影。
まず、ここではPHP(developphp.comから変更されたコード)からのFlashVarsを集めるメインのタイムラインからのアクションです:
// 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
}
が続いてここに(もdevelopphp.comから修正)PHP
です
<?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)は、URLクエリ文字列をFlash用のクエリ文字列に変換する便利な方法です。
私はこの簡単な作業を達成するためにハッキングやクラスのインポートを必要としないので、この方法をお勧めします。
が重複する可能性を](http://stackoverflow.com/questions/2725231/how-to-get-obtain-variables-from-url-in-flash-as3) –
これは重複している、答えはここで与えられたhttp:// stackoverflow .com/a/2725365 –