How to use the FileSystem in AIR to find the users directory folders

March 1st, 2008

I was messing around last night with AIR and I stumbled apon this:

  1. start an AIR app in flash cs3
  2. add a list component
    1. name it dir_list
  3. drop the code below in the actions panel
  4. And Viola!
  5. PS – PC people, I put a test to see if My Documents in in that Directory.

filestream.jpg

[as]

import flash.filesystem.*;

var userDirFiles:Array = File.userDirectory.getDirectoryListing();
for (var i:uint = 0; i < userDirFiles.length; i++) {
if (userDirFiles[i].isDirectory) {
//this.display_txt.text = String(userDirFiles[i].nativePath);
dir_list.addItem({label:userDirFiles[i].nativePath })
var tmpString:String = userDirFiles[i].nativePath;
if(tmpString.search(/My Documents/) != -1)
{

dir_list.addItem({label:”working”});
break;
}
}
} [/as]

Last 5 posts in actionscript

Last 5 posts in Apollo (AIR)

Last 5 posts in as3

Last 5 posts in flash

Last 5 posts in flash CS3

Entry Filed under: Apollo (AIR), actionscript, as3, flash, flash CS3

Leave a Comment

Required

Required, hidden

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Trackback this post  |  Subscribe to the comments via RSS Feed