开发者

How to get a random filename from a directory in AS3?

I need to get a random filename from a directory in AS3, and open it. (This will be online, so no AIR)

I'm thinking of just using a text/xml file with all the filenames listed, and just traverse through it getting the filename. But is ther开发者_开发百科e a more "direct" way to just look at the directory so I don't have to edit the text/xml file all the time?


If you have php (or equivalent) on your server, I would send this out to a php script.

Call your choseRandomFileFromFolder.php file, and have it simply return the path to the file it has selected at random. Then you don't have to edit the text/xml file.

A quick google found this handy function which does most of what you'll need. You might need to tweak it to filter types etc, but it shouldn't be difficult, even if you're new to php.

Instead of simply dying at the end, you'll want to pass back a urlEncoded named variable. Don't forget to urlescape your path!

http://www.jonasjohn.de/snippets/php/random-file.htm

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜