|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
directory listing/linking with CF and flash
well, i searched google for a while on how to list a directory in flash and i found that coldfusion can do this-along with some help from actionscript
![]() ColdFusion script: <cfdirectory directory="d:\inetpub\wwwroot\CFIDE" action="list" name="fileList"> <cfloop query="fileList"> <cfoutput>&file#fileList.currentRow#=#fileList.name#&</cfoutput> </cfloop> <cfoutput>&numFiles=#fileList.recordCount#&</cfoutput> Flash: var theRoot = this; var myLoadVars:LoadVars = new LoadVars(); myLoadVars.load("http://localhost:8500/devx/fileList.cfm"); myLoadVars.onLoad = function(){ for(var i=1;i<=myLoadVars.numFiles;i++){ theRoot.createTextField("t"+i,i*10,0,i*20,200, 20); theRoot["t" + i].text=myLoadVars["file"+i]; } } And its great...it works...but...the problem is i want links to the files and folders, so that people can click on the file to download it and click on a directory to go there.If you wanna see what it does now go here. Also, it'd be nice for it to show the directory that its displaying now..i dont need to use this script if you have any other alternatives as long as its flash...i wanna convert my site to flash, but its gonna be a file site...for LAN party's lol oh if the link doesnt work its because my computer is off..thx in advance! oh and btw this is what i use for html.. |
|
#2
|
|||
|
|||
|
All you need to do is use the name in conjunction with the URL to the directory that you are reading to create a full URL to each file.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
umm english please? >.< im a noob x_x i know almost nothing about actionscript and coldfusion...
|
|
#4
|
|||
|
|||
|
If the URL to the directory that you're displaying is http://mysite.com/files/, then you can construct a URL by using the name attribute of the file that you got using cfdirectory:
<cfdirectory name="dirList" action="list" directory="c:\inetpub\wwwroot\mysite\files"> <cfoutput query="dirList"><a href="http://mysite.com/files/#dirList.name#">#dirList.name#</a></cfoutput> Now how you do this in Flash I have no idea, never used Flash. |
|
#5
|
|||
|
|||
|
hmm doesnt work...this is the .cfm file i have after your suggestion..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <cfdirectory directory="d:\inetpub\wwwroot\CFIDE" action="list" name="fileList"> <cfloop query="fileList"> <cfoutput query="fileList"><a href="http://thenooblet.com/CFIDE/#fileList.name#">#fileList.name#</a></cfoutput> </cfloop> <cfoutput>&numFiles=#fileList.recordCount#&</cfoutput> </body> </html> the flash (which is set to just display the output of the cfm file with textboxes for each file) now, displays 11 "Undefined" lines (it says "undefined")...Theres 11 files/folders in the dir...now...i dont know if the flash would even display the files a links, but i dont think it should return "undefined"... -.- |
|
#6
|
|||
|
|||
|
But does it work without Flash, if you just execute the .cfm file directly in your browser?
|
|
#7
|
|||
|
|||
|
it displays this line over and over:
administratorApplication.cfmclassescomponentutilsdebuginstall.cfmmain.aspprobe.cfmregister.htmregist er_ja.htmscripts each word is a different link. at the end it has &numFiles=11& you can see it here |
|
#8
|
|||
|
|||
|
You're looping over the query twice. And you need a line break after each URL.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <cfdirectory directory="d:\inetpub\wwwroot\CFIDE" action="list" name="fileList"> <cfoutput query="fileList"><a href="http://thenooblet.com/CFIDE/#fileList.name#">#fileList.name#</a><br></cfoutput> <cfoutput>&numFiles=#fileList.recordCount#&</cfoutput> </body> </html> |
|
#9
|
|||
|
|||
|
hmm yea...the cfm works now except for the &numFiles=11& at the end (its still there) still...undefined in flash though...maybe ill take this to the flash section now that the cf pretty much works...maybe its that &numFiles=11& at the end though who knows...lol is it needed?
|
|
#10
|
|||
|
|||
|
Well you're putting that numFiles in there yourself, did you need it for something? If not, take this out:
<cfoutput>&numFiles=#fileList.recordCount#&</cfoutput> |
|
#11
|
|||
|
|||
|
And I have no idea how you are feeding this to Flash. If I were you I would look at using CFCs and Flash Remoting to send data to the Flash client. It's all in the docs.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > directory listing/linking with CF and flash |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|