PDA

View Full Version : How do I create flash file browser


ss_ram50
11-12-2005, 07:01 PM
Hello
I need a flash component which will be capable of performing file browsering from a directory which is located on the server.
And once the user selects double clicks one of the files (all in pdf format, for example) a new explorer window will be opened, which will open the selected file.
Thanks

seeFresh
11-12-2005, 08:11 PM
You will have to use a server side scripting language to communicate with flash i.e. php, asp, asp.net, perl, I've actually made one of these with asp.net. I don't think flash itself can get directory info. Not 100% sure of this, but 90%.

hope this helps

ss_ram50
11-12-2005, 10:12 PM
Thanks for the information
Do you have a reference Flash code which I can use?
Do you know if there is prepared component of Flash which already have this feature?

Flash Gordon
11-12-2005, 10:15 PM
scandir
(PHP 5 CVS only)

scandir -- List files and directories inside the specified path
Description
array scandir ( string directory [, int sorting_order])


Returns an array of files and directories from the directory. If directory is not a directory, then boolean FALSE is returned, and an error of level E_WARNING is generated.

By default, the sorted order is alphabetical in ascending order. If the optional sorting_order is used (set to 1), then sort order is alphabetical in descending order.


PHP code ---------

For PHP 4 use this:

<?php
$dir = "/tmp";
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}

sort($files);

print_r($files);

rsort($files);

print_r($files);

/* Outputs something like:
Array
(
[0] => .
[1] => ..
[2] => bar.php
[3] => foo.txt
[4] => somedir
)
Array
(
[0] => somedir
[1] => foo.txt
[2] => bar.php
[3] => ..
[4] => .
)
*/
?>

Flash Gordon
11-13-2005, 03:48 AM
Attached: Note that nothing in the scripts need to be changed. Upload the necessary files to ANY directory and watch the magic happen. Hope that helps. :)

<?php

$dir = getcwd();
$dh = opendir($dir);
while (($filename = readdir($dh)) == true) {
$files[] = $filename;
}

echo "&count=" . count($files);
for($i=0; $i<count($files); $i++) {
echo "&echo" . $i. "=" . $files[$i];
}

?>

var LV:LoadVars = new LoadVars();
LV.onLoad = function() {
for (i=0; i<LV.count; i++) {
_root.attachMovie("box", "box"+i+"_mc", i, {_x:20, _y:30*i});
_root["box"+i+"_mc"]._txt.text = LV["echo"+i];
}
};
LV.sendAndLoad("readDir.php", LV, "POST");

shunt
04-11-2007, 01:15 AM
Hey Flash! This looks like exactly what I need... I want Flash to make a list of files in a local folder on my computer. I've had a play with your code but I can't figure out how to make it work. I'm pretty new to Flash and know almost nothing about php - does php need to be installed on the local computer for it to work?

icktoofay
04-11-2007, 02:28 AM
Yes, it does. That would probably also require a web server base like Apache.

beele
12-30-2007, 06:30 PM
Sorry for the bump, I've been looking for such a thing for a long time.

Is there a way to make the files downloadable, and put the those links in a textbox with scrollbar??

Thanks in advance.

loisjune
01-09-2008, 03:54 PM
is it possible to make it as a button when clicked the file will be downloaded? or will be linked to another dynamic text field?

Horicolonoma
03-21-2009, 07:20 PM
Thanks, this helped me a lot and it is much better than combining this with XML.

so like the previous questioned: is it possible to make a loop in Flash to make links to different files in a directory?

jasotasticon
05-11-2009, 06:42 PM
Flash Gordon,

is there any way to make this script pull from multiple folders as specified in my actionscript?

This would be extremely helpful.

- Jason

solidus
11-19-2009, 07:04 PM
I take it no one figured out how to make the displayed PDF's clickable as dynamic buttons?

Thinking I was quite brilliant I added this piece of code but alas my mashed potatoe brains have failed me again:

var LV:LoadVars = new LoadVars();
LV.onLoad = function() {
for (i=0; i<LV.count; i++) {
_root.attachMovie("box", "box"+i+"_mc", i, {_x:20, _y:30*i});
_root["box"+i+"_mc"]._txt.text = LV["echo"+i];
_root.attachMovie("buttonSymbol", "btn", 1);
_root.btn.on (press) {
getURL(LV,"_blank");

}

}


}
};
LV.sendAndLoad("catalog/readDir.php", LV, "POST");