辛夷坞

涧户寂无人,纷纷开且落

By - Christen

HTML 插入 Flash 代码

How can you use HTML to configure your Flash content?
Specifications: http://www.w3.org/
Flash OBJECT and EMBED tag attributes

PConline 广告:

<object id="ad343696" class="pc.mobile.index.tl1-1." classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1110" height="90">
	<param name="flashvars" value="id=ad343696">
	<param name="movie" value="http://img.pconline.cn/ivy/foobar.swf">
	<embed name="ad343696" src="http://img.pconline.cn/ivy/foobar.swf" width="1110" height="90" flashvars="id=ad343696" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="opaque">
	<param name="wmode" value="opaque">
</object>

Alistapart: The <embed> element was created by Netscape as their method of embedding plug ins and players in web pages. It’s not part of the XHTML specification, and while some browsers other than Netscape support it, it’s not standards-compliant, so it’s out.
标准版本:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="foobar" align="middle">
	<param name="movie" value="foobar.swf" />
	<param name="quality" value="high" />
	<param name="bgcolor" value="#ffffff" />
	<param name="play" value="true" />
	<param name="loop" value="true" />
	<param name="wmode" value="window" />
	<param name="scale" value="showall" />
	<param name="menu" value="true" />
	<param name="devicefont" value="false" />
	<param name="salign" value="" />
	<param name="allowScriptAccess" value="sameDomain" />
	<!--[if !IE]>-->
	<object type="application/x-shockwave-flash" data="foobar.swf" width="550" height="400">
		<param name="movie" value="foobar.swf" />
		<param name="quality" value="high" />
		<param name="bgcolor" value="#ffffff" />
		<param name="play" value="true" />
		<param name="loop" value="true" />
		<param name="wmode" value="window" />
		<param name="scale" value="showall" />
		<param name="menu" value="true" />
		<param name="devicefont" value="false" />
		<param name="salign" value="" />
		<param name="allowScriptAccess" value="sameDomain" />
	<!--<![endif]-->
		<a href="http://www.adobe.com/go/getflash">
			<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>

来自:Flash CC
简化版本:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="myFlashMovie" align="middle">
    <param name="movie" value="myFlashMovie.swf" />
    <param name="flashvars" value="myVariable=Hello%20World&mySecondVariable=Goodbye" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="myFlashMovie.swf" width="550" height="400">
        <param name="movie" value="myFlashMovie.swf" />
        <param name="flashvars" value="myVariable=Hello%20World&mySecondVariable=Goodbye" />
    <!--<![endif]-->
        <a href="http://www.adobe.com/go/getflash">
            <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>

使用 SWFObject

<script src="http://libs.baidu.com/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
	var flashvars = {};
	flashvars.name1 = "hello";
	flashvars.name2 = "world";
	flashvars.name3 = "foobar";
	var params = {};
	params.menu = "false";
	var attributes = {};
	attributes.id = "myDynamicContent";
	attributes.name = "myDynamicContent";
	swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>
<div id="myContent">
  <p>Alternative content</p>
</div>

Adobe: Pass variables to SWFs | FlashVars
AS2:

text1.text = name1;

AS3:

// by querying the LoaderInfo object, set the value of paramObj to the
// to the value of the variable named myVariable passed from FlashVArs in the HTML
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters.name1;
// set the text of the text instance named text1. Use the toString() method
// to convert the value from an object to a string so it can be used in the text field
text1.text = paramObj.toString()

Advanced:

var tf:TextField = new TextField();       // create a TextField names tf
tf.autoSize = TextFieldAutoSize.LEFT;
tf.border = true;
addChild(tf);                             // add the TextField to the DisplayList so that it appears on the Stage
tf.appendText("params:" + "n");
try
{
    var keyStr:String;
    var valueStr:String;
    var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;   //set the paramObj variable to the parameters property of the LoaderInfo object
    for (keyStr in paramObj)
    {
        valueStr = String(paramObj[keyStr]);
        tf.appendText("t" + keyStr + ":t" + valueStr + "n");  // add each variable name and value to the TextField named tf
    }
}
catch (error:Error)
{
    tf.appendText(error.toString());
}

3 thoughts on “HTML 插入 Flash 代码

陈自新 December 31, 2014 at 1:20 pm

Flash 源文件下载:Pass variables to SWFs | FlashVars

Reply

陈自新 December 31, 2014 at 1:25 pm

CDN:百度公共 CDN

Reply

陈自新 December 31, 2014 at 6:26 pm

VM 上已经安装 Flash CS3 Flash CS6,主机上安装了 Flash CC,2015年,我来重点研究这个没落的技术。

Reply

Leave a Reply

Your email address will not be published.
*
*