在网页中传统嵌入flash方式,源码如下:
<OBJECT id=myFlash codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0
height=120 width=1000 classid=clsid27CDB6E-AE6D-11cf-96B8-444553540000>
<PARAM NAME="_cx" VALUE="26458">
<PARAM NAME="_cy" VALUE="3175">
<PARAM NAME="FlashVars" VALUE="">
<PARAM NAME="Movie" VALUE="toubu.swf">
<PARAM NAME="Src" VALUE="toubu.swf">
<PARAM NAME="WMode" VALUE="Window">
<PARAM NAME="Play" VALUE="0">
<PARAM NAME="Loop" VALUE="-1">
<PARAM NAME="Quality" VALUE="High">
<PARAM NAME="SAlign" VALUE="">
<PARAM NAME="Menu" VALUE="-1">
<PARAM NAME="Base" VALUE="">
<PARAM NAME="AllowScriptAccess" VALUE="always">
<PARAM NAME="Scale" VALUE="ShowAll">
<PARAM NAME="DeviceFont" VALUE="0">
<PARAM NAME="EmbedMovie" VALUE="0">
<PARAM NAME="BGColor" VALUE="">
<PARAM NAME="SWRemote" VALUE="">
<PARAM NAME="MovieData" VALUE="">
<PARAM NAME="SeamlessTabbing" VALUE="1">
<embed src="flash.swf" quality="high" width="1000"
height="120" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
name="myFlash" swLiveConnect="true">
</OBJECT>
在HTML网页中向swf传递参数。
方法一:在网页中使用js,SetVariable设置flashobject中的变量,代码如:
// "HtmlToSwf"为网页中的flashobject IDHtmlToSwf.SetVariable("_root.info_str","Happy Newyear");
方法二:路径参数,如test.swf?foo=happy2005
方法三:使用FlashVars,以下主要介绍FlashVars的用法。使用FlashVars后嵌入HTML的flashobject代码如下:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="550" height="400" id="FlashVars" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="FlashVars.swf" /><param name="FlashVars" value="foo=happy2005&program=flash&language=简体中文-中国" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="FlashVars.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="FlashVars" align="middle" allowScriptAccess="sameDomain" FlashVars="foo=happy2005&program=flash&language=简体中文-中国" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
通过上面的代码,在SWF(FlashVars.swf)中就可以直接获取foo、program、language变量数据。FlashVars.fla获取FlashVars参数的代码如下:
// 创建三个文本字段_root.createTextField("foo_txt",1,0,0,16,16);_root.createTextField("program_txt",2,0,32,16,16);_root.createTextField("language_txt",3,0,64,16,16);foo_txt.autoSize = true;foo_txt.border = true;program_txt.autoSize = true;program_txt.border = true;language_txt.autoSize = true;language_txt.border = true;// 获取FlashVars变量foo_txt.text = "HTML中的foo参数:"+foo;program_txt.text = "HTML中的program参数:"+program;language_txt.text = "HTML中的language参数:"+language;
以上都是网上找的,不过好象都是AS2.0的,在AS3.0中用不了