Home > Web Front-end > JS Tutorial > body text

SWFObject Flash js calling class_javascript skills

WBOY
Release: 2016-05-16 19:03:03
Original
942 people have browsed it

SWFObject is a Javascript-based Flash media version detection and embedding module. Its main purpose is to make it easier for us to embed FLASH into web pages. It adds a version detection function, conforms to XHTML standard verification insertion, and removes IE's FLASH click activation restrictions are compatible with mainstream browsers.
First let us look at a piece of code that works with SWFObject:
//Load the SWFObject class library


//Set a DIV and set the ID. This DIV will be inserted as FLASH Container

FlashPlayre8.0 is required to play this animation

//Use SWFObject to insert FLASH


What do you think after reading the above code? Compared with usual use of Object to insert FLASH files, is it much simpler, and the code structure is clearer? For the Chinese explanation of this code, please refer to AW's translation of SWFObject. It is already very detailed, so I won't go into details. I will only introduce myself below. Considered the most practical function.

1. Version detection

It is inevitable that there will be users whose player version is too low, and most of them are low-end users with little knowledge of computers. If they cannot see what we have pointed out FLASH animation, or because the player version does not support certain features in the new version, and the user sees incomplete animation, then this is a bad user experience, and users can easily blame all factors on product development. who. Practical SWFObject can avoid this trouble very well. When it detects that the user's player version is lower than the version we set, FLASH will not replace the content in the DIV container, so we can give the user a prompt here, for example: "You need to upgrade the FLASH player version to 8.0." If conditions permit, we can give users an upgrade link for Adobe's Flash Player here or directly provide an Active installation package for users to download and install.

2. Support for FlashVars

so.addVariable("arg1","test1"));
so.addVariable("arg2","test2"));
The above two lines of code will add two variables arg1=test1, arg2=test2 to the ROOT of FLASH in the form of FlashVars, which is simple and convenient. At the same time, we do not need to consider the compatibility issue of IE and FF.

Note: The communication between JS and FLASH is passed in string, so type conversion is required for the FLASH side of Number type variables.

3. Set FLASH inline parameters

so.addParam("wmode", "transparent");
This is the code we are familiar with to set FLASH background transparency, other inline parameters You can try setting the connection properties.

4. Get the variables in the URL

For URLs that use GET to pass variables like url?arg1=test1&arg2=test2, we can use the getQueryParamValue method to get the variables.

var t1 = getQueryParamValue("arg1"); alert(t1); Official address: <script></script>http://blog.deconcept.com/swfobject/<script> var so = new SWFObject("movie.swf", "mymovie", "200", "100", "7", "#336699"); <BR>//将id为flashcontent的DIV中内容替换为FLASH <BR>so.write("flashcontent"); <BR></script>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template