sendAndLoadVars flash to php to read xml

Hi there,

I am using senAndLoadVars to send data from flash to php then back to flash. My php file takes the var sent by flash in order to create an xml. When does php sends back the var or is successfully read by flash ???

I am encounting a prob where it seems that flash reads the xml created at the wrong time. Can somebody help or provide me with some solutions?? that problem is bugging me for a few days and i know there is one little thing that i am missing.


Flash:

var sendl:LoadVars = new LoadVars();
var receivel:LoadVars = new LoadVars();
    
//build the var to be sent to php
sendl.filedir = picFolder;

receivel.onLoad = function() {
    /*if(this.toFlash){
        test.testtxt.text = "Checking the php variable" +" "+ this.toFlash;
        loadXML();
    }else{
        test.testtxt.text = "not good";
    }*/

    if (success) {
        test.testtxt.text = "trying success";
        loadXML();
    }else{
        test.testtxt.text = "not good";
    }
}





MY php

//Reading the var sent from FLASH

if(isset($_GET['filedir'])){
    $file_dir = $_GET['filedir'];
    $dir=opendir("../../" . $file_dir);

    while (false !== ($file = readdir($dir)))//$file=readdir($dir) wrong way of reading
    {
        $ext = substr($file, strpos($file, ".")+1);
    
        if(array_search($file, $exclude_files)===false && array_search($ext, $allowed_formats)!==false){
            $f=$file_dir.'/'.$file;    
            $path []=$f;
        }
    }

    closedir($dir);
    
}

//$directory= $_SERVER['HTTP_HOST'] .$_SERVER['PHP_SELF'];
$directory= $_SERVER['PHP_SELF'];
$directory=dirname($directory);

//Removing words from modules
if($p = strpos($directory, "modules/")){
    $directory = substr($directory, 0, $p);
}

$galleryBgColor = "0x00ffff";

echo "<?xml version='1.0' encoding='iso-8859-1'?>
";

echo "<gallery_thumbs>
";
echo "<gallerySetUp>
";
echo "    <setUp bgColors=\"" .$galleryBgColor ."\"/>
";
echo "</gallerySetUp>
";
echo "<galleryBig>
";

    foreach ($path as $val) {
        echo "    <galleryPic location='http://localhost/yousemble_demo/images/flashgallery/gallery_001/002.jpg' />
";
        $t++;
    }
        
echo "</galleryBig>
";
echo "</gallery_thumbs>
";



Thanks for any help.

Regards,

Jerome