JavaScript 代码:
AC_FL_RunContent(
"src", "${swf}",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer",
"FlashVars", "param1=one¶m2=2¶m3=3¶m4=four"
);
如果不用 JavaScript 嵌入你的 Flex 3 编译的 SWF 文件,你也可以直接在 HTML 里面修改
<object> 和<embed>标签来实现:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="${application}" width="${width}" height="${height}"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="${swf}.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="${bgcolor}" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="FlashVars" value="param1=one¶m2=2¶m3=3¶m4=four" />
<embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
width="${width}" height="${height}" name="${application}" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer"
FlashVars="param1=one¶m2=2¶m3=3¶m4=four"
</embed>
</object>
在 Flex 应用程序里,你可以随时使用 Application.application.parameters 对象来访问 FlashVars
数据。下面这个 ActionScript 代码例子说明如何将四个 FlashVars 参数一一作为字符串访问,
然后在 TextArea 的文本域里显示它们。