How to embed flash in Web pages discussion _flash Tutorial

Source: Internet
Author: User

Flash embedded problems in the forum has been asked several times, in the end how to use, why not pass the verification, to pass the verification how to do, etc.
The discussion also appeared a lot of misunderstanding, so I just open a post summary of what I know, do not want to see my wordy direct jump to the final conclusion on it.

First, the traditional method

Copy Code code as follows:
<object classid= "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
Codebase= "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=7,0,0,0 "
Width= "height=" id= "Untitled-1" align= "Middle" >
<param name= "allowscriptaccess" value= "Samedomain"/>
<param name= "movie" value= "mymovie.swf"/>
<param name= "Quality" value= "High"/>
<param name= "bgcolor" value= "#ffffff"/>
<embed src= "mymovie.swf" quality= "High" bgcolor= "#ffffff" width= "550"
height= "Name=" "Mymovie" align= "Middle" allowscriptaccess= "Samedomain"
Type= "Application/x-shockwave-flash" pluginspage= "Http://www.macromedia.com/go/getflashplayer"/>
</object>

This method uses object and embed tags to embed, careful to find that many of the object's parameters and embed many of the attributes are duplicated, why do this? For browser compatibility, some browsers support object, some support embed, this is why to modify the parameters of the Flash two places have to change the reason. This method is Macromedia has always been the official method to maximize the guarantee of Flash functionality, there is no compatibility issues. But it's not working so well now:

Validation is not possible because embed tags embedded for compatibility do not conform to the rules of the consortium. Of course, if you don't care what the norm is not standard, another matter.

Microsoft for various reasons, in the SP2 after restricting the use of IE ActiveX mode, is in the page ActiveX has a virtual box, users need to click a time to normal interaction. Flash is embedded in the Web page as an ActiveX, so it will also be implicated, only through JS embedded in Flash to solve this problem.

No flash version detection, if the version of the Flash plugin version browser is not enough, or can not display your SWF file, or will pop up an ActiveX confirmation installation box-this box for many users is very scary.

Second, the method of using object only
The name of this method, called Flash Satay, was first published in 2002 by Drew McLellan on a List Apart, and then after several improvements:

Copy Code code as follows:
<object type= "Application/x-shockwave-flash
Data= "c.swf?path=movie.swf"
Width= "height=" >
<param name= "movie"
Value= "c.swf?path=movie.swf"/>
Width= "height=" "alt=" "/>
</object>
This method is not embed, can be verified, is the standard method of embedding Flash, browser compatibility is also good, looks almost perfect, but still problematic:

Need a holder SWF to load your target SWF to ensure the stream capability in IE, if you need to pass the flashvars to pass the parameter, or with the page JS interaction, will be very troublesome.

With the top 2nd, ActiveX problem with the virtual box.

Continue ditto no version detection

There are also a few user agents (such as some versions of Safari and some screen readers) that do not recognize this way and have bugs.

Third, using JS embedding method

With JS embedding is each have the embedding method, there is a good embedded has a bad embedded. Some people use document.write to write directly, this way to tell the truth is not good, feel hack ingredients, a bit for verification and verification of the meaning, and did not reflect what JS advantage. I think a good JS embedded script, in the guarantee that the Flash should be functional, based on ⒒? JS Advantage should have version detection, to be able to solve the problem of accessibility (that is, users can not browse the Flash content or disable JS when the problem should be handled), to be easy to reuse.
I know the more common JS embedding method has the following several

SWFObject

Ufo-unobtrusive Flash Objects

Macomedia (It's adobe now.) The script provided [here] and [here].

I use a lot of swfobject, just pick it up some of the advantages of this approach:

There is no annoying virtual box problem in IE.

Provides a complete version detection function, if the version is not enough to show other things, such as pictures or text. Easy to use, just load a. js file in the header and then HTML to write a container containing ordinary text or pictures (for display when Flash is not available), and finally replace the contents of this element with a script for Flash. It can be verified--of course it's not the point, it's just a passing effect.

Iv. My conclusions

At this stage with JS embedded Flash is the most perfect method, although this approach is also due to the various problems of browsers to make compromises.
But it is in the premise of ensuring Flash functionality also uses JS to provide additional benefits, and also has been written a very good embedded script can be used for the use of the Underground (recommended SWFObject), we have no reason why not it?

swfobject that Web page is in English, here is a simple tutorial to use :

Download its. js file, here: Http://blog.deconcept.com/swfobject/swfobject1-4.zip (if the link failure may be updated version, please use the address given above to download the latest version of the homepage)

Embed this script file in the Head

Write a container for Flash in your HTML, such as <div>, and give a random ID such as flashcontent. and put your replacement in there.

<div id= "Flashcontent" >
This replaces the content, which is displayed when Flash cannot be displayed.
</div>

Replace this content with a script:

Copy Code code as follows:
<script type= "Text/javascript" >
var so = new SWFObject ("movie.swf", "Mymovie", "MB", "7", "#336699");
Parameter meaning: address, Flash ID (not the ID of the container), wide, high, version requirements, background color
This is the most basic, if you want to advanced settings, just look over the instructions.
So.write ("Flashcontent");
</script>

This script can be written in HTML or written in an external. js file.

Ok

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.