Flash object和embed标签

Flash object和embed标签

object标签适用于ie浏览器,如:1、2
embed标签适用于所有浏览器,如:3、4
默认情况下两者结合使用,如:5、6

向flash内传递参数:
1、flashname.swf?p1=1&p2=11
2、FlashVars

生成flash的mxml文件源码如下:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="initVars(event)" backgroundColor="#CCCCCC">
 <fx:Declarations>
  <!-- 将非可视元素(例如服务、值对象)放在此处 -->
 </fx:Declarations>
 <fx:Script>  
  <![CDATA[
   import mx.core.FlexGlobals;
   import mx.events.FlexEvent;
  
   [Bindable]
   public var p1:String;
   [Bindable]
   public var p2:String;
  
   private function initVars(event:FlexEvent):void {
    p1 = FlexGlobals.topLevelApplication.parameters.p1;
    p2 = FlexGlobals.topLevelApplication.parameters.p2;
   }
  ]]>  
 </fx:Script>  
 <s:Label text="{p1}" x="50" y="10" />
 <s:Label text="{p2}" x="100" y="10" />
</s:Application>


插入flash的html文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Flash object和embed标签</title>
<script type="text/javascript" src=\'#\'" /script>
</head>

<body>
1:<br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="300" height="30">
  <param name="movie" value="gp4.swf" />
  <param name="quality" value="high" />
  <param name="FlashVars" value="p1=1&p2=11" />
</object>
<br />
2:<br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="300" height="30">
  <param name="movie" value="gp4.swf?p1=2&p2=22" />
  <param name="quality" value="high" />
  <param name="FlashVars" value="" />
</object>
<br />
3:<br />
<embed src=\'#\'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="30" FlashVars="p1=3&p2=33"></embed>
<br />
4:<br />
<embed src=\'#\'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="30" FlashVars=""></embed>
<br />
5:<br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="300" height="30">
  <param name="movie" value="gp4.swf" />
  <param name="quality" value="high" />
  <param name="FlashVars" value="p1=5&p2=55" />
  <embed src=\'#\'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="30" FlashVars="p1=5&p2=55"></embed>
</object>
<br />
6:<br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="300" height="30">
  <param name="movie" value="gp4.swf?p1=6&p2=66" />
  <param name="quality" value="high" />
  <param name="FlashVars" value="" />
  <embed src=\'#\'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="30" FlashVars=""></embed>
</object>
<br />
7:<br />
<div id="my_chart"></div>
<script type="text/javascript">
swfobject.embedSWF("gp4.swf?p1=7&p2=77", "my_chart", "300", "30", "9.0.0", "expressInstall.swf", {} );
</script>
<br />
8:<br />
<div id="my_chart2"></div>
<script type="text/javascript">
swfobject.embedSWF("gp4.swf", "my_chart2", "300", "30", "9.0.0", "expressInstall.swf", {"p1":"8","p2":"88"} );
</script>
</body>
</html>

参考:http://blog.csdn.net/fax5201314/article/details/2044967
 

你可能感兴趣的:(object,Flash,EMBED)