SWFObject Flash JS Call class _javascript Tips

Source: Internet
Author: User
SWFObject is a JavaScript-based Flash media version of the detection and embedding module, its main purpose is to let us flash embedded in the Web page of the operation is simpler, adding a version detection function, compliant with XHTML standard validation inserts, And the release of IE on the flash click Activation restrictions, compatible with the mainstream browser.
First, let's look at a piece of code that swfobject function:
Load SWFObject class Library
<script type= "Text/javascript" src= "Swfobject.js" src= "Swfobject.js" ></script>
Set a div and set the ID, this div will be the container for flash insertion
<div id= "Flashcontent" > Play this animation requires flashplayre8.0+ </div>
Use SWFObject to insert Flash
<script type= "Text/javascript" > var so = new SWFObject ("movie.swf", "Mymovie", "M", "M", "7", "#336699");
Replace content in Div with ID flashcontent with flash
So.write ("Flashcontent");
</script>
How does it feel to look at the code above? Compared with the usual use of object to insert a Flash file is more concise, and the structure of the code more clearly, the Chinese interpretation of this code can be seen in the SWFObject translation, has been very detailed, no longer repeat, the following only describes the most practical functions of the individual.

First, version detection

Inevitably there is a player version too low user, and most of them are low-end users, the knowledge of the computer is shallow, if they do not see the Flash animation we pointed out, or because the player version does not support the new version of some features, users see the incomplete animation, then this is a bad user experience, It is easy for users to blame all factors on the developer of the product. Practical swfobject can be very good to avoid this trouble, when it detects that the user's player version is lower than the version we set, Flash will not replace the contents of the div container, so we can give users a hint here, for example: "You need to upgrade the Flash Player version to 8.0+." If the conditions permit, we can give the user an upgrade link to an Adobe Flashplayer or directly provide an active installation package to the user to download the installation.

Ii. support for the Flashvars

So.addvariable ("Arg1", "test1"));
So.addvariable ("Arg2", "test2"));
The above two code will be flashvars to the flash root to add two variables arg1=test1,arg2=test2, simple, convenient, without us to consider the compatibility of IE and ff.

Note: JS and Flash communications are passed in string, so for the number-variable flash end need to do type conversion.

Third, set flash inline parameters

So.addparam ("wmode", "Transparent");
This is our familiar set of flash background transparent code, other inline properties can try to set.

Get the variables in the URL

For Url?arg1=test1&arg2=test2 to pass a variable in a get way, we can use the Getqueryparamvalue method to obtain the variable.

var T1 = getqueryparamvalue ("Arg1");
alert (t1);
Official address: http://blog.deconcept.com/swfobject/

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.