SWFObject 2.1 and later versions

Source: Internet
Author: User

However, the previous call method is a little complicated. First, instantiate it and add parameters, variables, and write data, which is just as troublesome as installing an elephant in the refrigerator. Fortunately, the author finally noticed this in the new 2. in Version x, the simplest call requires only one sentence and does not need to wait for the page to load. This means that you can write this sentence anywhere on the page, it can be seen that human science and technology are improving rapidly. Next we will list several call instances that are most commonly used in daily development.

1. the simplest and most basic sentence you can use to insert flash

Copy codeThe Code is as follows:
<SCRIPT src = "swfobject. js" type = text/javascript> </SCRIPT>
<SCRIPT type = text/javascript>
Swfobject. embedSWF ("xiedaima.swf", "yourFlashContainer", "300", "120", "9.0.0", "expressInstall.swf ");
</SCRIPT>

Annotation: Call method embedSWF -- Insert the SWF file. The parameters are
@ Swf file address;
@ Id of the container (such as div) used to load the swf file;
@ Flash width;
@ Flash height (of course, the width and height can be expressed by a percentage such as 100% );
@ The lowest version required for normal playback of the flash;
@ When the version is earlier than the required version, execute the swf file. Here, use this flash to go to the official download of the latest flash plug-in. (This parameter can be omitted)

When inserting multiple flash files to different locations on the same page, you only need to repeat the preceding statement and use different container IDs.

2. Call methods for passing parameters, variables, and attributes to the swf File

Copy codeThe Code is as follows:
<SCRIPT src = "swfobject. js" type = text/javascript> </SCRIPT>
<SCRIPT type = text/javascript>
// 1. Use Json to initialize variables, parameters, and attributes
Var flashvars = {
Name1: "hello ",
Name2: "world ",
Name3: "foobar"
};
Var params = {
Menu: "false"
};
Var attributes = {
Id: "dynamicContent2 ",
Name: "dynamicContent2"
};
Swfobject. embedSWF ("test6_flashvars.swf", "content2", "300", "120", "6.0.0", "expressInstall.swf", flashvars, params, attributes );

// 2. Traditional initialization settings have 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", "300", "120", "6.0.0", "expressInstall.swf", flashvars, params, attributes );
// 3. Write it directly at the back end, just a word, concise and tough, without dragging the water
Swfobject. embedSWF ("xiedaima.swf", "content5", "300", "120", "6.0.0", "expressInstall.swf", {name1: "hello", name2: "world ", name3: "xiedaima" },{ menu: "false" },{ id: "dynamicContent5", name: "dynamicContent5 "});
</SCRIPT>

Finally, we call the embedSWF method to embed it into flash. The parameter sequence is also very clear. I prefer to call the method in 1st, which is easy to use.
Package

Related Article

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.