Tell a friend

WHO AM I

Latest Medical News from Bio-Medicine.Org

Latest Biology News from Bio-Medicine.Org

<bgsound src="your_sound_file"></bgsound>

GAME

Search This Blog

gupshup

game play

s

tinychat

donut chat

CRIMINAL

jw player

In this tutorial, we'll explain the best options to embed Flash.
Note - We highly recommend that you use SWFObject v1.5 for your Flash embedding. In fact, we like it so much that we use it for all of the embedding on this site. Detailed instructions can be found below.
The Object Tag and The Embed Tag

There's a lot of confusion about the code needed to properly embed Flash objects within a website. A great deal of this confusion can be attributed to the fact that there's no standard way to do it - Internet Explorer uses the tag, while Firefox, Safari, Chrome, and Opera use the tag.
Let's start with the easiest way to embed Flash in a website — a single or tag.
tag syntax







tag syntax


Note - this example presumes there's a player.swf file located in the same directory as the HTML page it's embedded in. If you're planning on using JavaScript, please don't or tags as JavaScript interaction does not work with an embed code; you'll need to use the SWFObject method for that.
Of these parameters, the most important one is the src and the movie. This contains the location of the SWF file to include, (here player.swf). If the SWF file resides in another directory, we can point to it with a relative path (e.g. flash/player.swf or an absolute path (e.g. http://www.myserver.com/flash/player.swf).
The width and height parameters determine the SWF's dimensions in pixels, but they can also be entered as a percentage of the SWF container (e.g. width="100%").
The allowscriptaccess parameter allows the SWF to communicate with external scripts (and link to external pages), while allowfullscreen uses the fullscreen mode. If you do not want to allow this, you can remove both parameters, since they default to sameDomain and false, respectfully.
id and name are the identifiers for the player within the page. This is what allows for player control via JavaScript and styling of the player.
Finally, the flashvars parameter specifies the variables that will be loaded in the SWF. The JW Player uses these extensively, as it specifies the player's configuration.
Extra Parameters

The code listed above uses only a few of the available parameters. A complete list of them can be found at Adobe's website. Here's a brief list of the most interesting parameters:
bgcolor (#rrggbb): sets the SWF background color using a hexadecimal value.
menu (true, false): set this to false to hide most of the right-click menu.
wmode (opaque, transparent, window): set this to either transparent or opaque to fix z-index or flickering issues.
The Object / Embed Method

By themselves, and tags won't work in every browser. Thankfully, it's possible to nest the tag within the tag in such a way that it will work with all browsers. Using our example above,







XHTML & JavaScript

Even though the object / embed method works in all browsers, isn't a valid XHTML tag. So, if you want to build a standards-compliant, accessible website, you cannot use it.
Thankfully, there is a workaround. You can use JavaScript to embed Flash content. After a web page has loaded you can insert the tag, circumventing the XHTML problems. As a bonus, you can use JavaScript to determine whether the correct Flash Plugin is available on your visitor's computer. If not, alternative content can be loaded.
SWFObject

The SWFObject script by Geoff Stearns is an excellent, freely available JavaScript that embeds Flash. It's used extensively on this site, and it's our recommended method for embedding Flash content.
First, you'll need to upload the swfobject.js to your server and include it in the section of your website:

Next, give the HTML element in which the SWF should be placed a unique id:
This will be replaced by the SWF.

Finally, you'll need to instantiate a SWFObject below the named HTML element along with all the necessary parameters (for a full list of parameters, visit the SWFObject Website). This varies between versions of SWFObject, but we've included an example from each to guide you.
SWFObject 1.5 (recommended)


SWFObject 2.X


The SWFObject instance will create the code needed to embed the player.swf. It sets its dimensions to 300 x 250 pixels and also sends the flashvars for the file and autostart variables.The instance also replaces the text by the SWF, so we can see a Flash movie directly embedded in our page without borders but with XHTML validity.

No comments:

Post a Comment