First, a little bit about how SWFObject works. Here’s an excerpt from the blog.deconcept.com/swfobject site:
Here’s an example of how you would use SWFObject.
<div id="flashcontent1"><strong>You need to upgrade your Flash Player</strong> This is replaced by the Flash content. </div>
The code above defines the section of the page that will contain the Flash content. I can also be used to display information to users that do not have the Flash player installed. So far, so good.
The next line calls a method of the SWFObject instance variable called addVariable. This method allows me to pass a variable name and value into the Flash movie. Normally this is done using FlashVars.
The last line calls the write method of the instance variable to write the completed Object/Embed tag into the div tag shown in the second code block.
<cfimport prefix="socf" taglib="/cfswfobject/com">
Use CFImport to access the custom tags in the cfswfobject folder.
Call the swfobjectinit custom tag to initialize the SWFObject functionality.
So how do I call the custom tags to include my Flash movie?
<socf:cfswfobject name="antique-analog-clock.swf" width="206" height="246" version="8" bgcolor="ffffff"> <socf:sovar varname="myName" value="David Bailey" /> </socf:cfswfobject>
Use the cfswfobject and sovar custom tags to include the Flash movie in the template. As you can see I use the prefix specified in the cfimport tag to refer to the cfswfobject custom tag. I use several user defined attributes to pass values inside the custom tag. I then have a child custom tag that allow me to set a variable name/value that will be passed into the Flash movie.
So what does the cfswfobject custom tag look like?
First I create a variable instance of the SWFObject, passing into its method the values I passed into the custom tag.
Second I get the number of associated attributes I may have for this custom tag. This code along with the code in the child custom tag, sovar.cfm, allow the parent custom tag (this one) access any attributes passed into the child custom tag. The child custom tag receives a varname and value. Those two values are made accessible due to the code in child custom tag.
As I continue through the loop I call the addVariable method of the swfObject instance in order to pass values into the Flash movie.
So what do this sovar.cfm custom tag do?
<cfif ThisTag.ExecutionMode IS 'Start'> <!--- Associate local attributes to <cf_cfswfobject> ---> <cfassociate basetag="cf_cfswfobject"> </cfif>
The most important thing it does is to define a relationship between the child custom tag (this one) and its parent (cfswlonject.cfm). It does this by using the cfassociate tag. We identify the parent tag by specifying it name (using the prefix of cf_) in the basetag attribute.
And that’s it. Now you can simply include those few lines of CF code to safely include your Flash movie.