Hi, I'm Brian Reavis.
I'm a Front-end Engineer at DIY. I love mountains.

Adobe AIR provides great references to common locations on a user’s computer that map to the right place depending on the operating system.

It’s missing one, however: File.downloadsDirectory. Here’s what would work:

/**
 * File.downloadsDirectory
 *
 * Returns the appropriate location to place downloaded files.
 * (falls back to the Desktop)
 */ 
public function get downloadsDirectory():File {
   var downloadsDirectory:File;
 
   downloadsDirectory = File.userDirectory.resolvePath('Downloads');
   if (downloadsDirectory.isDirectory) return downloadsDirectory;
 
   downloadsDirectory = File.documentsDirectory.resolvePath('Downloads');
   if (downloadsDirectory.isDirectory) return downloadsDirectory;
 
   return File.desktopDirectory;
}

Copyright © 2012 – Brian Reavis. All rights reserved. The views expressed here are my own and do not necessarily reflect the views of DIY.