issamneo
05-21-2004, 05:21 AM
hi everybody
i want to put in an flash array the names of files found in a directory
this the php script:
<?
$i = 0;
$dir = ".";
$handle=opendir($dir);
while ($file = readdir($handle)) {
if($file=='.'||$file=='..')
continue;
$filetlist [$i] = $file;
$i++;
}
$numRows = count($filetlist);
print "&total=$numRows";
for ($i=0; $i<$numRows; $i++){
echo "&file$i=".$filetlist [$i];
}
?>
and there is th AS 2 script:
GetPaths = new LoadVars();
flasharray = new Array;
GetPaths.onLoad = function(success) {
var x:Number ;
x = this.total;
for (i=0;i<x;i++){
flasharray[i]=GetPaths["file"+i];
trace ("number"+i+" " +flasharray[i]);
}
};
GetPaths.sendAndLoad("http://127.0.0.1/test/test3.php", GetPaths, "POST");
// GetPaths["file"+i]
for(j=0;j<flasharray.length;j++){
trace (flasharray[j]);
}
why when i trace the flasharray[i] in the loop for (i=0;i<x;i++) it sends the name of files it's OK but
after when i trace them: for(j=0;j<flasharray.length;j++) it don't work WHY!!!
i want to put in an flash array the names of files found in a directory
this the php script:
<?
$i = 0;
$dir = ".";
$handle=opendir($dir);
while ($file = readdir($handle)) {
if($file=='.'||$file=='..')
continue;
$filetlist [$i] = $file;
$i++;
}
$numRows = count($filetlist);
print "&total=$numRows";
for ($i=0; $i<$numRows; $i++){
echo "&file$i=".$filetlist [$i];
}
?>
and there is th AS 2 script:
GetPaths = new LoadVars();
flasharray = new Array;
GetPaths.onLoad = function(success) {
var x:Number ;
x = this.total;
for (i=0;i<x;i++){
flasharray[i]=GetPaths["file"+i];
trace ("number"+i+" " +flasharray[i]);
}
};
GetPaths.sendAndLoad("http://127.0.0.1/test/test3.php", GetPaths, "POST");
// GetPaths["file"+i]
for(j=0;j<flasharray.length;j++){
trace (flasharray[j]);
}
why when i trace the flasharray[i] in the loop for (i=0;i<x;i++) it sends the name of files it's OK but
after when i trace them: for(j=0;j<flasharray.length;j++) it don't work WHY!!!