# Flash list documents (doc, pdf, xls...) in a folder

**URL:** <https://forum.kirupa.com/t/flash-list-documents-doc-pdf-xls-in-a-folder/313194>\
**Category:** flash\
**Created:** [August 23, 2010, 3:19pm UTC](https://forum.kirupa.com/t/flash-list-documents-doc-pdf-xls-in-a-folder/313194 "2010-08-23T15:19:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manuelcorrea66](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@manuelcorrea66](https://forum.kirupa.com/u/manuelcorrea66)\
**Post date:** [August 23, 2010, 3:19pm UTC](https://forum.kirupa.com/t/flash-list-documents-doc-pdf-xls-in-a-folder/313194/1 "2010-08-23T15:19:55Z")

</div>

I want to dynamically list documents by link (path  
ame) that a user can click on and get redirect (or bring the document up in flash) using flash (CS3).

I already know (through hours of research) that I need an xml file created in php or asp to load from flash - e.g. xmlDocument.Load(“source.php”) - to list these files. I have tried every combination of php and flash code to acheive this but nothing works.

one example:

[COLOR=red]**PHP: (file name source.php in same directory as fla/swf and forms - where the documents are - is subdirectory in that same directory)**[/COLOR]

\<?php  
// Set which extensions should be approved in the XML file  
$extensions = array  
(  
‘doc’, ‘DOC’,  
‘pdf’, ‘PDF’,  
‘xls’, ‘XLS’,  
‘pub’, ‘PUB’  
);  
// Echo the header (XML)  
header(“Content-Type: application/xml;charset=ISO-8859-1”);  
// Prepare the XML file  
echo ‘\<?xml version=“1.0” encoding=“ISO-8859-1”?\>’ . "  
";

// Get the files from the current directory  
if (file\_exists ("/forms"))  
{  
if (is\_dir ("/forms"))  
{  
$dh = opendir ("/forms") or die (" Directory Open failed !");

// Prepare the images array  
$imgs = array();  
while ($file = readdir ($dh))  
{  
// Only get the files ending with the correct extension  
if ( in\_array( substr($file, -3), $extensions ) )  
{  
array\_push($imgs, $file);  
}  
}  
Closedir ($dh);  
}

// Sort the array  
sort($imgs);

echo "\<images\>  
";  
foreach ($imgs as $img)  
{  
// Return all images in XML format  
echo (’ \<image\>’ . $img . ‘\</image\>’);  
echo "  
";  
}  
}  
echo “\</images\>”;  
?\>

[COLOR=red] **FLASH:** [/COLOR]  
[FONT=Times New Roman][SIZE=3]this.createTextField(“my\_txt”, this.getNextHighestDepth(), 28, 200, 320, 100);[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]my\_txt.autoSize = “left”;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]my\_txt.border = true;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]my\_txt.multiline = true;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]my\_txt.wordWrap = true;[/FONT][/SIZE]

[SIZE=3][FONT=Times New Roman]var reviews\_xml:XML = new XML();[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]reviews\_xml.ignoreWhite = true;[/FONT][/SIZE]

[SIZE=3][FONT=Times New Roman]// When XML data is loaded, execute this function[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]reviews\_xml.onLoad = function (success:Boolean):Void [/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]{[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]if (success)[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]{[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]var childItems:Array = reviews\_xml.firstChild.childNodes;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]for (var i:Number = 0; i \< childItems.length; i++) [/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]{ [COLOR=red] **This line never executes as if childItems.length = 0** [/COLOR][/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman] my\_txt.text += childItems\*.firstChild.firstChild.nodeValue + "  
";[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]}else[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]{[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]my\_txt.text = “Unable to load external file.”;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]reviews\_xml.load(“source.php”);[/FONT][/SIZE]
