View Full Version : Is there a way to read how many files are in a folder with AS?
tedc
September 8th, 2006, 11:08 AM
?
Since I dont want to set up a DB for such a tiny task, I was wondering if there's any way to do this!
If not in AS, in PHP?
creatify
September 8th, 2006, 12:30 PM
yep, you can use php - here is a sample of the php and the call from flash. './flvs' is the directory right next to the php file in the case below. Also, I just stripped htis out of something I use, so you'll have to edit the loadvars items.
<?php
$flist = "flist=";
if ($handle = opendir('./flvs')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$flist .= $file.",";
}
}
echo($flist);
closedir($handle);
}
?>
and in flash
var t:Object = this;
var nLv:LoadVars = new LoadVars();
var t:Object = new Object();
nLv.onLoad = function(success:Boolean) {
if(success) {
for(var i in this) {
var m:String = i;
if(typeof(this[m])=="string") {
t.dirFiles = this[m].split(",");
t.dirFiles.splice(t.dirFiles.length-1,1);
//call my funciton when finished stashing
//all items into and t Object
setUpMenuBtns();
}
}
} else {
trace("failed...")
}
}
nLv.sendAndLoad(phpFilesPath, nLv, "POST");
tedc
September 8th, 2006, 01:29 PM
Great, thanks! I'll have to study a little on how to implement this, but Im looking forward to it :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.