swfObject 使用说明

1.Embed your SWF with JavaScript

使用方法  swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes, callbackFn) 包含5个必须参数及5个可选参数。

  1. swfUrl (String, required) specifies the URL of your SWF
  2. id (String, required) specifies the id of the HTML element (containing your alternative content) you would like to have replaced by your Flash content
  3. width (String, required) specifies the width of your SWF
  4. height (String, required) specifies the height of your SWF
  5. version (String, required) specifies the Flash player version your SWF is published for (format is: "major.minor.release" or "major")
  6. expressInstallSwfurl (String, optional) specifies the URL of your express install SWF and activates Adobe express install. Please note that express install will only fire once (the first time that it is invoked), that it is only supported by Flash Player 6.0.65 or higher on Win or Mac platforms, and that it requires a minimal SWF size of 310x137px.
  7. flashvars (Object, optional) specifies your flashvars with name:value pairs
  8. params (Object, optional) specifies your nested object element params with name:value pairs
  9. attributes (Object, optional) specifies your object's attributes with name:value pairs
  10. callbackFn (JavaScript function, optional) can be used to define a callback function that is called on both success or failure of creating a Flash plug-in <object> on the page (see API documentation)

注意:可选的参数你可以忽略,或者给它传递false值即可,对于flashvars,params,attributes参数,你也可以传递空对象{}.

 

2.How can you configure your Flash content?

你可以为attributes 对象指定如下可选的属性:

  • id (NOTE: when undefined, the object element automatically inherits the id from the alternative content container element)
  • align
  • name
  • styleclass (see note about class)
  • class

styleclass 与class 都是指定样式,但因为class是js中的关键字,所以如果使用class时要用引号括起来。

Example:

var attributes = {
   id: "myId",
   align: "left",
   styleclass: "myclass"
};

If you would rather use class instead of styleclass, wrap the word class in quotes like this:

var attributes = {
   id: "myId",
   align: "left",
   "class": "myclass"
};

 

你还可以为params对象指定如下可选的属性:

3.你可以忽略flashvars参数,而使用params对象的flashvars属性指定:

<script type="text/javascript">

var flashvars = false;
var params = {
  menu: "false",
  flashvars: "name1=hello&name2=world&name3=foobar"
};
var attributes = {
  id: "myDynamicContent",
  name: "myDynamicContent"
};

swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);

</script>

官方文档:https://code.google.com/p/swfobject/wiki/documentation

属性参数值配置:http://helpx.adobe.com/flash/kb/flash-object-embed-tag-attributes.html

使用flashvars参数传值到swf:http://helpx.adobe.com/flash/kb/pass-variables-swfs-flashvars.html

posted @ 2014-03-29 10:33  code_flyer  阅读(425)  评论(0编辑  收藏  举报