Why is JavaScript becoming so important to Flash?
It's no secret that with the new Microsoft vs. Eolas issues that have come to light, that Flash developers are striving to continue using and developing their craft and skills, while at the same time not eliminating the majority of their visitors.
There are a few alternatives to the embed tag. Ironically, all of which still use "embed technology." They simply do not use them directly, which is what the entire Microsoft vs. Eolas issue is all about...using "embed technology" directly, to embed media into web pages.
Flash developers are quickly finding that JavaScript is probably the most widely accepted method above others. It also adds a bit of cross-page interactive abilities, allowing any portion of the page to interact externally with Flash.
The many uses of JavaScript with Flash
While JavaScript will most likely be the chosen method to include Flash in web pages, as mentioned above, it also has numerous other abilities, that allow other, external, attributes of the web page to interact with the included Flash.
I will explain how to include Flash in your pages using This may get kind of long so hang in there with me.
Using JavaScript to include Flash in your movie
The easiest, and quickest way to embed your Flash animation into your page is by calling and external JavaScript or .js file, in the precise place you wish to include your Flash movie.
Using the following steps, you'll be able to embed any movie quickly, using JavaScript:
Step 1.
Open your favorite text editor. I prefer CrimsonEditor, but you can use any text editor you want. Enter your basic Flash embed code, in the following format:
Why is JavaScript becoming so important to Flash?
It's no secret that with the new Microsoft vs. Eolas issues that have come to light, that Flash developers are striving to continue using and developing their craft and skills, while at the same time not eliminating the majority of their visitors.
There are a few alternatives to the embed tag. Ironically, all of which still use "embed technology." They simply do not use them directly, which is what the entire Microsoft vs. Eolas issue is all about...using "embed technology" directly, to embed media into web pages.
Flash developers are quickly finding that JavaScript is probably the most widely accepted method above others. It also adds a bit of cross-page interactive abilities, allowing any portion of the page to interact externally with Flash.
The many uses of JavaScript with Flash
While JavaScript will most likely be the chosen method to include Flash in web pages, as mentioned above, it also has numerous other abilities, that allow other, external, attributes of the web page to interact with the included Flash.
I will explain how to include Flash in your pages using This may get kind of long so hang in there with me.
Using JavaScript to include Flash in your movie
The easiest, and quickest way to embed your Flash animation into your page is by calling and external JavaScript or .js file, in the precise place you wish to include your Flash movie.
Using the following steps, you'll be able to embed any movie quickly, using JavaScript:
Step 1.
Open your favorite text editor. I prefer CrimsonEditor, but you can use any text editor you want. Enter your basic Flash embed code, in the following format:
document.write( "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n" );
document.write( " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,42,0\"\n" );
document.write( " id=\"Movie1\" width=\"500\" height=\"300\">\n" );
document.write( " <param name=\"movie\" value=\"Movie1.swf\">\n" );
document.write( " <param name=\"menu\" value=\"false\">\n" );
document.write( " <param name=\"quality\" value=\"best\">\n" );
document.write( " <param name=\"wmode\" value=\"transparent\">\n" );
document.write( " <param name=\"bgcolor\" value=\"#CCCCCC\">\n" );
document.write( " <embed name=\"Movie1\" src=\"Movie1.swf\"\n" );
document.write( " menu=\"false\" quality=\"best\" wmode=\"transparent\" bgcolor=\"#CCCCCC\" swLiveConnect=\"true\"\n" );
document.write( " width=\"500\" height=\"300\"\n" );
document.write( " type=\"application/x-shockwave-flash\"\n" );
document.write( " pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>\n" );
document.write( "</object>\n" ); |
The idea is to place all of your html lines between document.write(" and "); Making sure to place a backslash (\) before every quotation mark, or you will most certainly have parse errors. Even if you don't know what a "parse error" is, be assure that it's not good, and will cause your movie not to show up. I suggest looking at the above code carefully to see where I have placed the backslashes before each quotation mark.
Step 2:
Save this file with any name you wish, but make sure to give it a .js extension
Example (movie1.js)
Step 3:
Place the following line of code in your page, where you want your animation to appear
<script language="JavaScript" type="text/javascript" src="movie1.js"></script>
<noscript>It's best to put a still image shot of your flash here for those that don't have JavaScript enabled</noscript> |
Notice the src of the above code is the name of the js file you made in step 1 and 2. The "noscript" tag below this code makes sure that those who do not have JavaScript enabled on their browser, will still see the same overall look of your site. Basically it can be used to replace your flash animation with an image, or something other than the flash animation.
That’s all there is to it!
Keep an eye out for a new article, and I’ll explain how to control your movie across windows, using JavaScript.