# Dynamic Buttons pulled from a directory

**URL:** <https://forum.kirupa.com/t/dynamic-buttons-pulled-from-a-directory/300357>\
**Category:** flash\
**Created:** [November 19, 2009, 6:41pm UTC](https://forum.kirupa.com/t/dynamic-buttons-pulled-from-a-directory/300357 "2009-11-19T18:41:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Solidus](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@Solidus](https://forum.kirupa.com/u/Solidus)\
**Post date:** [November 19, 2009, 6:41pm UTC](https://forum.kirupa.com/t/dynamic-buttons-pulled-from-a-directory/300357/1 "2009-11-19T18:41:43Z")

</div>

Hey guys,  
I have a directory of PDF’s that I am loading the names of dynamically using PHP:

My PHP file looks like this:

```auto

<?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];
}

?>

```

And my Actionscript looks like this:

```auto
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("catalog/readDir.php", LV, "POST");

    

```

Now the code works perfect and it displays the name of all the pdf’s but I want to somehow make a button on top of each displayed pdf that makes it clickable.  
The code is already storing the name of the PDF’s so it should be pretty easy to do a  
getURL(“pdfname”,“blank”) or whatever I just don’t know where to start.

Here is the SWF output: [https://ssl.perfora.net/s246612274.onlinehome.us/securitronftp/test/getFiles.swf](https://ssl.perfora.net/s246612274.onlinehome.us/securitronftp/test/getFiles.swf)
