A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Fixing code [F8]

  1. #1
    Senior Member
    Join Date
    Jan 2001
    Location
    IT
    Posts
    213

    Fixing code [F8]

    Hi guys,

    I know that it might appear as a strange request but if you could help me I'll appreciate it.
    Now the point is that I needed a script which would read the content of a folder storing some images for creating a gallery. I've used the following php script to read the directory:
    <?php
    $dir = "../images/".$cartella."/";
    //$dir = 'path/to/the/directory';
    $numfiles = 0;
    if (is_dir($dir)) {
    if ($openDir = opendir($dir)) {
    while (false !== ($file = readdir($openDir))) {
    if ($file != '.' && $file != '..') {
    if (is_file($dir . '/' . $file)) {
    $f = explode('.', $file);
    $ext = array_pop($f);
    if ($ext == 'jpg') {
    echo "&filename$numfiles=$file";
    ++$numfiles;
    }
    }
    }
    }
    }
    closedir($openDir);
    }

    ?>

    At this point I needed to pass a variable called 'cartella' from flash which created the stumble point. After different tries I've came up with this solution :

    var lv = new LoadVars();
    lv.onLoad = function(ok) {
    if (ok) {
    var i = 0;
    while (this["filename"+i] != undefined) {
    trace(this["filename"+i]);
    ++i;
    }
    } else {
    displai.htmlText += "ERROR";
    }
    };

    cartella = "mock";
    lv.load("flash/read.php?cartella="+cartella, "POST");

    Now, don't take me bad for this, it works but somehow I don't feel fully satisfied with it. Could you have a look to the AS and point me which would have been the right way (if any) to write the code? Especially in the 'load' bit!

    Thanks for your time
    Giano

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    add the variable to the LoadVars Object -
    PHP Code:
    var lv = new LoadVars();
    lv.cartella "mock";
    lv.sendAndLoad("flash/read.php"lv"POST");

    lv.onLoad = function(ok) { .... }; 
    hth

  3. #3
    Senior Member
    Join Date
    Jan 2001
    Location
    IT
    Posts
    213
    Thanks a lot man, I've tried using sendAndLoad but with no results obviously I was missing something.

    Anyway thanks a lot

    Giano

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    but with no results

    try to declare the POST variable in php -

    $cartella = $_POST['cartella'];

    hth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center