开发者

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 co开发者_运维百科ntents of a folder in a list. basically populate the list from a directory insread of from the xml.


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.


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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜