我正在尝试将 URL/GET 变量加载到要在 AS3 中使用的 FlashVar 中。它只是在 AS3 中追溯为未定义。
这是我的 JS($_GET['building'] 设置为某些东西并正确回显):
<script type="text/javascript" src="<?php echo site_url(); ?>js/swfobject.js"></script>
<script type="text/javascript">
<?php if(isset($_GET['building'])){ ?>
var flashvars = { building: '_<?php echo $_GET['building']; ?>' };
<?php } else { ?>
var flashvars = { };
<?php } ?>
var params = {};
var attributes = {};
swfobject.embedSWF("PlanEventTool_cs5-1.swf", "flashContent", "900", "700", '9.0.0', '<?php echo site_url(); ?>js/expressInstall.swf', flashvars, params, attributes);
</script>
还有我的 AS3:
var allFlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
buildingString = String(allFlashVars['building']);
trace(buildingString);
一直在看这个,我确定我错过了一些小东西。
有任何想法吗?
渲染的 JS:
var flashvars = { };
flashvars.building = "_grandstand";
var params = {};
var attributes = {};
var flashObj = "PlanEventTool_cs5-1.swf?t=" + new Date().getTime(); // anti-cahce
swfobject.embedSWF(flashObj, "flashContent", "900", "700", '9.0.0', 'expressInstall.swf', flashvars, params, attributes);
呈现的 HTML:
<object width="900" height="700" type="application/x-shockwave-flash" data="PlanEventTool_cs5-1.swf?t=1334695440505" id="flashContent" style="visibility: visible;"><param name="flashvars" value="building=_grandstand"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><param name="AllowNetworking" value="all"></object>