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 has added version detection function, and has inserted the standard verification of XHTML. It has lifted the restrictions on FLASH click activation by IE, and is compatible with mainstream browsers.
First, let's look at a piece of code that works for SWFObject:
//Load the SWFObject class library
<script type="text/javascript" src="" src=""></script>
//Set a DIV and set the ID. This DIV will be used as a container inserted by FLASH.
<div >FlashPlayre8.0+ is required to play this animation</div>
//Use SWFObject to insert FLASH
<script type="text/javascript"> var so = new SWFObject("", "mymovie", "200", "100", "7", "#336699");
//Replace the content in the DIV with id flashcontent with FLASH with FLASH
("flashcontent");
</script>
How do you feel after reading the above code? Is it much more concise than using Object to insert FLASH files? 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 and will not be repeated. The following will only introduce the functions I think are the most practical.
1. Version detection
It is inevitable that there are users with too low player versions, and most of them are low-end users and have a low understanding of computer knowledge. If they cannot see the FLASH animation we pointed out, or because the player version does not support certain features in the new version and users see broken animations, then this is a bad user experience, and users can easily blame the product developers for all factors. 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 the conditions allow, we can give the user a link to Adobe's FlashPlayer to upgrade or directly provide an Active installation package for the user to download and install.
2. Support for FlashVars
("arg1","test1"));
("arg2","test2"));
The above two codes will add two variables arg1=test1 and arg2=test2 to FLASH's ROOT in FlashVars, which is concise and convenient. At the same time, we don't need to consider the compatibility issues between IE and FF.
Note: JS and FLASH communication is passed in strings, so type conversion is required for the FLASH side of Number type variable.
3. Set FLASH inline parameters
("wmode", "transparent");
This is the code we are familiar with to set the transparent FLASH background. You can try setting other inline properties.
4. Get variables in the URL
For the URL of a variable using GET method such as url?arg1=test1&arg2=test2, we can use the getQueryParamValue method to get the variable.
var t1 = getQueryParamValue("arg1");
alert(t1);
Official address:/swfobject/
First, let's look at a piece of code that works for SWFObject:
//Load the SWFObject class library
<script type="text/javascript" src="" src=""></script>
//Set a DIV and set the ID. This DIV will be used as a container inserted by FLASH.
<div >FlashPlayre8.0+ is required to play this animation</div>
//Use SWFObject to insert FLASH
<script type="text/javascript"> var so = new SWFObject("", "mymovie", "200", "100", "7", "#336699");
//Replace the content in the DIV with id flashcontent with FLASH with FLASH
("flashcontent");
</script>
How do you feel after reading the above code? Is it much more concise than using Object to insert FLASH files? 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 and will not be repeated. The following will only introduce the functions I think are the most practical.
1. Version detection
It is inevitable that there are users with too low player versions, and most of them are low-end users and have a low understanding of computer knowledge. If they cannot see the FLASH animation we pointed out, or because the player version does not support certain features in the new version and users see broken animations, then this is a bad user experience, and users can easily blame the product developers for all factors. 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 the conditions allow, we can give the user a link to Adobe's FlashPlayer to upgrade or directly provide an Active installation package for the user to download and install.
2. Support for FlashVars
("arg1","test1"));
("arg2","test2"));
The above two codes will add two variables arg1=test1 and arg2=test2 to FLASH's ROOT in FlashVars, which is concise and convenient. At the same time, we don't need to consider the compatibility issues between IE and FF.
Note: JS and FLASH communication is passed in strings, so type conversion is required for the FLASH side of Number type variable.
3. Set FLASH inline parameters
("wmode", "transparent");
This is the code we are familiar with to set the transparent FLASH background. You can try setting other inline properties.
4. Get variables in the URL
For the URL of a variable using GET method such as url?arg1=test1&arg2=test2, we can use the getQueryParamValue method to get the variable.
var t1 = getQueryParamValue("arg1");
alert(t1);
Official address:/swfobject/