How can you embed flash on a page and still have it validate?

notValid
asked by Dion Davis, a student in Phoenix

Maintaining page validation while embedding flash can be a pain for anyone. Most people try to drop the swf onto their page in dreamweaver, in this case dreamweaver will try its best to write a little code for you to make it work. The problem is that it doesn’t validate. In my opinion the easiest way to accomplish this is use the SWFObject JavaScript.

What you are going to end up doing is downloading the swfobject.js file and link to it in your site, then you will write a little bit of JavaScript that describes where the swf file is, and also it’s specs.

First, download the SWFobject.js, in this folder there will be the swfobject.js file as well as a few examples on how you can use it.

There a ton of different parameters that you can use in your JavaScript that you are using to embed it, but I usually start with the same 6 and adjust it from there.

Embedding the Flash

Example - Using SWFObject

<div id=“flash”>
<div id=‘noflash’>
<p>To view this, you need to install the Flash Player 7.

Please go <a href=‘http://www.adobe.com/products/flashplayer/’ title=‘Get Flash’>
here and download it</a>.</p>

</div><noscript>

<ins>

<strong>Note:</strong> JavaScript is also required.

</ins>

</noscript>

<script type=‘text/javascript’>

// <![CDATA[

var so = new SWFObject(’swf/header.swf’, ‘flash-header’, ‘500′, ‘200′, ‘7′, ‘#fff’);

so.addParam(’quality’, ‘high’);

so.addParam(’menu’, ‘false’);

so.addParam(’wmode’, ‘transparent’);

so.addVariable(’scale’, ‘noscale’);

so.write(’noflash’);

// ]]>

</script>

</div>

The top div called noflash is what gets displayed when the user doesn’t have flash installed, it will then prompt them to download it. The second part is the important part, the JavaScript. These are my default settings and the only things I usually change are the top line of it.

This line is the one to worry about,

var so = new SWFObject(’swf/header.swf’, ‘flash-header’, ‘500′, ‘200′, ‘7′, ‘#fff’);

This line is saying this,

var so = new SWFObject(’link to the swf’, ‘ID of the object’, ‘width’, ‘height’, ‘required flash version’, ‘color that appears behind the flash while it is loading’);

Try using this method and replacing the information with yours, if you have any problems you may follow up in the comments below. I have used this method on my San Diego web design site with success as well.