tbarber210
asked on
Loading a SWF file using a coldfusion variable
Hello!
I have a website on which I need to display a .swf tutorial. There are 50+ different tutorial files. I would like to use 1 page to display the tutorials and just dynamically pass the swf file name into the object tag.
I have a database in which I store the .swf file name and it's associated topic ID. So the information stored in the database is:
TopicID, fileLocation (example: 1, myfile)
I'm passing the topicID through a URL variable which then drives my query:
<cfquery datasource="mydatabase" name="getCurrentTopic">
SELECT fileLocation
FROM Topics
WHERE TopicID = #url.location#
</cfquery>
If I quickly output the results of this query - it is displaying the correct fileLocation - so that much is working.
After that query, I have the following code:
<object classid="clsid:d27cdb6e-ae 6d-11cf-96 b8-4445535 40000" width="750" height="500" id="<cfoutput query="getCurrentTopic">#f ileLocatio n#</cfoutp ut>" align="middle">
<param name="movie" value="<cfoutput query="getCurrentTopic">#f ileLocatio n#</cfoutp ut>.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockw ave-flash" data="<cfoutput query="getCurrentTopic">#f ileLocatio n#</cfoutp ut>" width="750" height="500">
<param name="movie" value="<cfoutput query="getCurrentTopic">#f ileLocatio n#</cfoutp ut>.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
The .swf file is located in the same directory as the .cfm file. However, when I load this page, I only get a large white box and the "get flash" image/link. The swf file does not load.
I tried testing using the same structure on an <img> tag for an image file (that has the same name as the swf file except that it has a .jpg extension) and that works perfectly. I just can't seem to get the object tag to take my cf variable.
Thoughts?
I have a website on which I need to display a .swf tutorial. There are 50+ different tutorial files. I would like to use 1 page to display the tutorials and just dynamically pass the swf file name into the object tag.
I have a database in which I store the .swf file name and it's associated topic ID. So the information stored in the database is:
TopicID, fileLocation (example: 1, myfile)
I'm passing the topicID through a URL variable which then drives my query:
<cfquery datasource="mydatabase" name="getCurrentTopic">
SELECT fileLocation
FROM Topics
WHERE TopicID = #url.location#
</cfquery>
If I quickly output the results of this query - it is displaying the correct fileLocation - so that much is working.
After that query, I have the following code:
<object classid="clsid:d27cdb6e-ae
<param name="movie" value="<cfoutput query="getCurrentTopic">#f
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockw
<param name="movie" value="<cfoutput query="getCurrentTopic">#f
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
The .swf file is located in the same directory as the .cfm file. However, when I load this page, I only get a large white box and the "get flash" image/link. The swf file does not load.
I tried testing using the same structure on an <img> tag for an image file (that has the same name as the swf file except that it has a .jpg extension) and that works perfectly. I just can't seem to get the object tag to take my cf variable.
Thoughts?
ASKER
#fileLocation# includes the file name without the extension. So if the file name is myfile.swf, #fileLocation# contains "myfile".
Interestingly enough, when I try the "FileExists" function, it says that the file does not exist.
However, if I change over the embedding code to to be an <Object> tag with an internal <embed> tag, it does display. Perhaps there is something about the newer <object> & <object> code sequence that doesn't allow it to display properly? I'm not sure... but I do get the file to display with the <object> and <embed> tags.
It does have problems if I try to move the file into a subfolder (for organization purposes), it will not let me do:
<OBJECT classid="clsid:D27CDB6E-AE 6D-11cf-96 B8-4445535 40000"
WIDTH="750" HEIGHT="500" id="<cfoutput query="getCurrentTopic">#f ileLocatio n#</cfoutp ut>">
<PARAM NAME=movie VALUE="<cfoutput query="getCurrentTopic">sw f/#fileLoc ation#.swf </cfoutput >">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="<cfoutput query="getCurrentTopic">sw f/#fileLoc ation#.swf </cfoutput >" quality=high bgcolor=#FFFFFF WIDTH="800" HEIGHT="600"
NAME="<cfoutput query="getCurrentTopic">#f ileLocatio n#</cfoutp ut>" ALIGN="" TYPE="application/x-shockw ave-flash" >
</EMBED>
I'm not sure why the FileExists function doesn't find the file though...
Interestingly enough, when I try the "FileExists" function, it says that the file does not exist.
However, if I change over the embedding code to to be an <Object> tag with an internal <embed> tag, it does display. Perhaps there is something about the newer <object> & <object> code sequence that doesn't allow it to display properly? I'm not sure... but I do get the file to display with the <object> and <embed> tags.
It does have problems if I try to move the file into a subfolder (for organization purposes), it will not let me do:
<OBJECT classid="clsid:D27CDB6E-AE
WIDTH="750" HEIGHT="500" id="<cfoutput query="getCurrentTopic">#f
<PARAM NAME=movie VALUE="<cfoutput query="getCurrentTopic">sw
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="<cfoutput query="getCurrentTopic">sw
NAME="<cfoutput query="getCurrentTopic">#f
</EMBED>
I'm not sure why the FileExists function doesn't find the file though...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah! That fixed it! Thanks for the help... it's now working perfectly!
Welcome :)
http://yourserver.com/path/to/yourFile.swf OR ...
/path/to/yourFile.swf OR ...
yourFile.swf <=== relative to *.cfm script
Verify the file actually exists. If it does, try temporarily hard coding the value.
<cfif FileExists("/path/to/yourF
....
<param name="movie" value=""/path/to/yourFile.