SWFObject Flash js call class

Source: Internet
Author: User

SWFObject is a Javascript-based Flash Media Version Detection and embedding module. Its main purpose is to make it easier to embed FLASH into webpages and add the version detection function, it complies with the XHTML standard, removes the restriction on FLASH click activation by IE, and is compatible with mainstream browsers.
First, let's look at the code used by SWFObject:
// Load the SWFObject class library
<Script type = "text/javascript" src = "swfobject. js" src = "swfobject. js"> </script>
// Set a DIV and an ID. This DIV will be used as the container for FLASH insertion.
<Div id = "flashcontent"> FlashPlayre8.0 + is required to play the animation. </div>
// Use SWFObject to insert FLASH
<Script type = "text/javascript"> var so = new SWFObject ("movie.swf", "mymovie", "200", "100", "7 ", "#336699 ");
// Replace the content in the DIV with FLASH Content
So. write ("flashcontent ");
</Script>
After reading the above Code, how does it feel? It is much simpler to insert a FLASH file using an Object than usual, and the code structure is clearer. For the Chinese explanation of this Code, see AW's Translation of SWFObject, I will not repeat it here. I will only introduce what I think is the most practical function.

I. Version Detection

There will inevitably be users with low Player versions, and most of them are low-end users. They have a low understanding of computers. If they do not see the FLASH animation we have mentioned, or because the Player version does not support some features in the new version and users see incomplete animations, this is a poor user experience. Users can easily blame all the factors on product developers. SWFObject can be used to avoid this problem. When it detects that the user's Player version is earlier than the version we set, FLASH will not replace the content in the DIV container, therefore, we can prompt you here, for example, "you need to upgrade the Flash Player version to 8.0 + ". If conditions permit, we can here give you an Adobe Flash Player upgrade link or directly provide an Active installation package for users to download and install.

Ii. FlashVars support

So. addVariable ("arg1", "test1 "));
So. addVariable ("arg2", "test2 "));
The above two pieces of code add two variables arg1 = test1 and arg2 = test2 to the flash root in FlashVars mode, which are concise and convenient, at the same time, we do not need to consider the compatibility between IE and FF.

Note: JS communicates with FLASH by passing strings. Therefore, type conversion is required for the FLASH end of the Number variable.

3. Set FLASH inline Parameters

So. addParam ("wmode", "transparent ");
This is the code that we are very familiar with to set the transparent FLASH background. You can set other inline attributes.

4. Get the variables in the URL

For url? Arg1 = test1 & arg2 = test2 and pass the variable URL in GET mode. We can use the getQueryParamValue method to GET the variable.

Var t1 = getQueryParamValue ("arg1 ");
Alert (t1 );
Official Address: http://blog.deconcept.com/swfobject/

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.