The easiest way to include Adobe Flash SWFs in your sites
Inserting Flash into your web pages
In order to place Flash .swf files in your pages, you need a bit of special code. The code is fairly complex so I have written a bit of JavaScript to simplify the process. In reality, all you should have to know to put an animation in your page are three things:
- The name of the .swf document
- The width of the object
- The height of the object
Alternatively, you might want to include a name so that you can style the flash with some CSS. If you want to use this more than once on a single page, then you should put this code within the
tag.
<script>
function writeFlash(movieLocation,mywidth,myheight,myname) {
if (myname) { myid=myname; } else { myid="flashanimation"; }
document.write('<object type="application/x-shockwave-flash"id="'+myid+'"width="'+mywidth+'"height="'+myheight+'"data="'+movieLocation+'"> <param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+movieLocation+'" /><param name="quality" value="high" /><param name="scale"value="noscale" /><param name="wmode" value="transparent"/></object>');
}
</script>
This javascript takes four parameters, which are obvious from their names. Wherever you want the Flash to show on the page, you simply call it like this:
<script>
writeFlash('mymovie.swf',600,300,'myMovie');
</script>
If you want to use this on multiple pages, you should copy the first piece of code containing the function and put it on a separate text file. When you do, make sure you DON'T include the beginning and ending <script> tag. Let's say we call the new text file we created "writeflash.js", so in the <head> tag, write the following.
<script src="writeflash.js" type="text/javascript"></script>
You can place this code on any webpage that will need to call the .SWF file. If you have a header file that loads on every page on your site, it would be easier to place it there.