How to Externalize Flash Coding & JavaScript
One day out of curiosity, I was looking to see how I could
How to Externalize the Flash coding. Needless to say it did take
a bit of searching to find something on the internet that was
suffice. The coding that can be externalized is the coding in
the embed tag. The example below will guide you through the
process. After the flash example, we will touch on externalizing
JavaScript. Externalizing Flash Coding
Just as you can externalize JavaScript to reduce the amount of
coding in your webpage, you can also do the same with your flash
coding. The coding that ends up getting externalized is the coding
in the embed tags. Please note that you have to include the embed
tags as well. In the example below, the highlighted coding in the
regular version is the coding that will be externalized in a .as
file which we will call flash.as. The code will end up
looking like #include "flash.as".
Regular Version
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
id="flashHeader"
name="flashHeader"
width="723"
height="236">
<param name="movie" value="http://www.YourFancyDomainName.org/flash/header.swf?section=home">
<param name="quality" value="high">
<param name="wmode" value="transparent">
<param name="menu" value="false">
<param name="base" value="/">
<embed src="http://www.YourFancyDomainName.org/flash/header.swf?section=home"
width="723"
height="236"
quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash"
wmode="transparent"
base="/"
swLiveConnect="true"
name="flashHeader"
menu="false">
</embed>
</object>
Externalized Version
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
id="flashHeader"
name="flashHeader"
width="723"
height="236">
<param name="movie" value="http://www.YourFancyDomainName.org/flash/header.swf?section=home">
<param name="quality" value="high">
<param name="wmode" value="transparent">
<param name="menu" value="false">
<param name="base" value="/">#include
"flash.as"
</object>
As you can see, the amount of coding has be greatly reduced and it
is no harder than externalizing the JavaScript.
Externalizing
JavaScript
Externalizing the JavaScript for your pages is not too
hard. All you have to do is take the code between the script tags
and place it in a JS file. Using the example below, the coding
highlighted in green will be placed in a file that will be called
hello.js. The one additional change that you will have to make
is on the opening script tag, you will have to add src="http://www.AFreakyDomainNameHere.com/hello.js".
You can see the changes below in the before and after examples.
Before <SCRIPT LANGUAGE="JavaScript">
<!--
function Hello ()
{
alert("Hello
World!")
}
//-->
</SCRIPT> After <SCRIPT TYPE="text/javascript"
src="http://www.AFreakyDomainNameHere.com/hello.js">
</SCRIPT>
So that's really all there is too it. You will find out that not
all JavaScript will be able to be externalized. Always test it out
on a sample page first before going live on your site. Gerard Manning
Search Engine Placement Specialist
Search Engine Marketing Agency :: Manning
Search Marketing

|