Skip to main content
August 29, 2012
Answered

AS3, get file names in folder with Flash .exe or .app, not Air

  • August 29, 2012
  • 2 replies
  • 7139 views

I'm building a Flash project that will read a folder to get the names of pictures & videos so they can be added dynamically to the Flash project. The .swf, .app or .exe, however I output the final version, will run on a PC or Mac that's hooked up to a large flat screen monitor.

If the project was being used on the web I'd just call a .php script to dump the file names into an .xml file. However, the Flash & computer will be offline.

I'm haven't built anything with AIR so I don't have enough time to get up to speed with it in order to use it. I know AIR's AS3 has a FileListEvent class that has the getDirectoryListingAsync method to read a directory.

So my question is, is there a way to read the names of a directory from a folder when the Flash is running offline?

I was wondering if running a DOS script or a Mac DOS-like script would be do-able.

Or is there a better way?

Thanks in advance for your reply,

Zak

This topic has been closed for replies.
Correct answer

AIR isn't a bad option if you're using Flash Pro CS5.5+ already and don't mind updating the libraries and app. Be sure the target machine also has the latest AIR installed as well (I think CS6 allows captive runtime otherwise).

I merely recommended XAMPP because you mentioned you'd just do it with a PHP script on the web so I recommended that based on familiarity.

Good luck!


sinious,

a co-worker of mine told me that apache & .php are built into Mac OS X. there's a good chance i'll be running the flash on a Mac so I can take advantage of this option.

http://foundationphp.com/tutorials/php_leopard.php

Zak

2 replies

sinious
Legend
August 29, 2012

Your options are a bit limited. Flash has absolutely no access to reading the filesystem beyond you explicitly telling it what file to read. There's more to using AIR than just trying to use its libraries so if time is of the essence that won't help you.

You can manage an XML file yourself as you said you'd have a PHP script generate. It might be that "it will just had to do" answer.

You can set up a self installable XAMPP server and use PHP as you mentioned, offline.

If you can spend some money then I highly recommend MDM Zinc. It is a projector extender that gives you many abilities in an AIR-like way and you can even write plugins for it if the built-in library doesn't have what you need. I use it quite often. I also have Screentime's mProjector which is similar but I find Zinc to be far more updated and feature full.

Lastly you can literally write some kind of server and use the sockets Flash supports (TCP, UDP) to communicate with it to do the dirty work.

I think the local webserver is probably your best option. It's free, easy and familiar.

August 29, 2012

Thanks for the suggestions sinious,

I'll look into converting the flash into an AIR project so I can use the file Class.

Depending on my time contraints, it's a rush job, I might have to install the XAMPP server and run the .php script offline.

Zak

Correct answer
August 30, 2012

AIR isn't a bad option if you're using Flash Pro CS5.5+ already and don't mind updating the libraries and app. Be sure the target machine also has the latest AIR installed as well (I think CS6 allows captive runtime otherwise).

I merely recommended XAMPP because you mentioned you'd just do it with a PHP script on the web so I recommended that based on familiarity.

Good luck!


sinious,

a co-worker of mine told me that apache & .php are built into Mac OS X. there's a good chance i'll be running the flash on a Mac so I can take advantage of this option.

http://foundationphp.com/tutorials/php_leopard.php

Zak

August 29, 2012

You can't do it with Flash alone, and trying to get some OS script to work on both mac and PC is going to be problematic at best. You're going to just need to bite the bullet and use AIR, it's not that hard... Here's an example to get you going:

http://troyworks.com/blog/2008/11/09/air-listing-files-in-directory/