RapsFan1981
RapsFan1981

Reputation: 1197

Actionscript flash.filesystem

I made an mp3 player that populates a list with filenames from an xml file but I want to be able to display the contents of a folder in a list. basically populate the list from a directory insread of from the xml.

Upvotes: 0

Views: 256

Answers (2)

Marty
Marty

Reputation: 39456

You could do this via FlashVars if you wanted to parse a list of files to flash using scandir() in PHP. Otherwise, like said, you'll have to use AIR.

The PHP is quite easy anyways; I'd try something similar to this (note this is a really rough example):

Page:

<?php
    $arr = scandir("your_directory");
    $joined = implode('#', $arr);

    echo '
    <object width="x" height="y">
        <param name="flashvars" value="files=' . $joined . '" />
        <embed src="media.swf?files=' . $joined . '" width="x" height="y" />
    </object>';
?>

AS3:

var vars:Object = root.loaderInfo.parameters;
var files:Array = vars.files.split("#");

var i:String;
for each(i in files)
{
    doStuffWith(i);
}

function doStuffWith(file:String):void
{
    // load file etc
}

Upvotes: 0

prototypical
prototypical

Reputation: 6751

Flash doesn't allow you to access the local file system in that way. You should look into AIR, as it allows you to do this type of thing. Since AIR is also AS3 based, you won't need to change much code at all, if any. You'll just need to implement the local storage access part.

Upvotes: 1

Related Questions