SWFObject more than 2.1 version of syntax introduction _javascript skills

Source: Internet
Author: User
However, the previous method of invocation is really a bit cumbersome, first instantiate-> add parameters, variable-> write, with the elephant in the fridge as trouble. Fortunately, the author finally noticed this, In the new 2.x version, the simplest call is just one sentence, and there's no need to wait for the page to load, which means you can write that down anywhere on the page, and this shows that human technology is progressing faster, so let's enumerate a few of the invocation examples we use most often in our daily development.

1, the simplest, most basic, as long as you want to insert Flash can use the classic word

Copy Code code as follows:

<script src= "Swfobject.js" type=text/javascript></script>
<script type=text/javascript>
swfobject.embedSWF ("xiedaima.swf", "Yourflashcontainer", "the" "," "," "9.0.0", "expressinstall.swf");
</SCRIPT>

Annotations: Invoking method embedswf--Inserts a SWF file, which in turn is
The address of the @swf file;
@ The ID of the container (such as DIV) that is used to mount the SWF file;
The width of the @flash;
The height of the @flash (of course, the width here can be expressed in percentages such as 100%);
@ Normal playback of the minimum required version of the Flash;
@ When the version is below the requirement, execute the SWF file, use this flash to go to the official download the latest version of the Flash plugin. (This parameter can be omitted)

When you insert multiple flash to a different location on the same page, just repeat the above statement and use a different container ID.

2, to the SWF file transfer parameters, variables, properties of the call method

Copy Code code as follows:

<script src= "Swfobject.js" type=text/javascript></script>
<script type=text/javascript>
1. Initialize variables, parameters, properties using JSON
var flashvars = {
name1: "Hello",
Name2: "World",
Name3: "Foobar"
};
var params = {
Menu: "False"
};
var attributes = {
ID: "DynamicContent2",
Name: "DynamicContent2"
};
swfobject.embedSWF ("test6_flashvars.swf", "Content2", "the" "," "6.0.0", "expressinstall.swf", flashvars, params, attributes);

2, the traditional initialization settings, the same effect
var flashvars = {};
flashvars.name1 = "Hello";
Flashvars.name2 = "World";
Flashvars.name3 = "Xiedaima";
var params = {};
Params.menu = "false";
var attributes = {};
Attributes.id = "DynamicContent3";
Attributes.name = "DynamicContent3";
swfobject.embedSWF ("xiedaima.swf", "Content3", "the" "," "6.0.0", "expressinstall.swf", flashvars, params, attributes);
3, write directly in the back, on the word, concise fierce, not muddy
swfobject.embedSWF ("xiedaima.swf", "content5", "," "," "6.0.0", "expressinstall.swf", {name1: "Hello", name2: " World ", Name3:" Xiedaima "}, {menu:" false "}, {id:" DYNAMICCONTENT5 ", Name:" DYNAMICCONTENT5 "});
</SCRIPT>

Finally, call the embedSWF method embedded in Flash, the parameters of the order is also very clear, I prefer the 1th call method, see not tired, and convenient.
Package Download Address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.