日期:2014-05-17  浏览次数:20675 次

html向swf传递变量

1. js方式

?

var flashvars = {
??? ??? ??? ??? lastname:"king5"
??? ??? ??? };
??????????? var params = {};
??????????? params.quality = "high";
??????????? params.bgcolor = "#ffffff";
??????????? params.allowscriptaccess = "sameDomain";
??????????? params.allowfullscreen = "true";
??????????? var attributes = {};
??????????? attributes.id = "FlashVar";
??????????? attributes.name = "FlashVar";
??????????? attributes.align = "middle";
??????????? swfobject.embedSWF(
??????????????? "FlashVar.swf", "flashContent",
??????????????? "100%", "100%",
??????????????? swfVersionStr, xiSwfUrlStr,
??????????????? flashvars, params, attributes);
??? ??? ??? <!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
??? ??? ??? swfobject.createCSS("#flashContent", "display:block;text-align:left;");

?

?

2. object方式(2边都要加)

?

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="FlashVar">
??????????????? <param name="movie" value="FlashVar.swf?lastname=king1" />
??????????????? <param name="quality" value="high" />
??????????????? <param name="bgcolor" value="#ffffff" />
??????????????? <param name="allowScriptAccess" value="sameDomain" />
??????????????? <param name="allowFullScreen" value="true" />
??? ??? ??? ??? <param name="FlashVars" value="lastname=king" />
??????????????? <!--[if !IE]>-->
??????????????? <object type="application/x-shockwave-flash" data="FlashVar.swf?lastname=king2" width="100%" height="100%">
??????????????????? <param name="quality" value="high" />
??????????????????? <param name="bgcolor" value="#ffffff" />
??????????????????? <param name="allowScriptAccess" value="sameDomain" />
??????????????????? <param name="allowFullScreen" value="true" />
??? ??? ??? ??? ??? <param name="FlashVars" value="lastname=king" />
??????????????? <!--<![endif]-->
??????????????? <!--[if gte IE 6]>-->
??????????????? ??? <p>
??????????????? ??? ??? Either scripts and active content are not permitted to run or Adobe Flash Player version
??????????????? ??? ??? 10.0.0 or greater is not installed.
??????????????? ??? </p>
??????????????? <!--<![endif]-->
??????????????????? <a href="http://www.adobe.com/go/getflashplayer">
??????????????????????? <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
??????????????????? </a>
??????????????? <!--[if !IE]>-->
??????????????? </object>
??????????????? <!--<![endif]-->
??????????? </object>

?

?

3. as接收

public function initial():void {
??? ??? ??? ??? var paras:String = FlexGlobals.topLevelApplication.parameters.lastname ;
??? ??? ??? ??? Alert.show(paras);
}