Below is a screencast of an application I wrote called FileTile in order to validate the new storage volume APIs in AIR 2:
Detecting the mounting and unmounting of a storage volume in AIR 2 is very easy. The code below shows using the new StorageVolumeInfo class to register for mount and unmount events:
StorageVolumeInfo.storageVolumeInfo.addEventListener(StorageVolumeChangeEvent.STORAGE_VOLUME_MOUNT, onVolumeMount);
StorageVolumeInfo.storageVolumeInfo.addEventListener(StorageVolumeChangeEvent.STORAGE_VOLUME_UNMOUNT, onVolumeUnmount);
Below are the two functions that react to the mounting and unmounting of storage volumes:
private function onVolumeMount(e:StorageVolumeChangeEvent):void
{
if (e.storageVolume.isRemovable)
{
this.nativeWindow.activate();
this.volumeName.text = e.storageVolume.name;
this.targetVolume = e.storageVolume.rootDirectory;
this.currentVolumeNativePath = this.targetVolume.nativePath;
this.start();
}
}
private function onVolumeUnmount(e:StorageVolumeChangeEvent):void
{
if (this.currentVolumeNativePath == e.rootDirectory.nativePath)
{
this.reset();this.mainView.selectedChild = instructionBox;
}
}
FileTile is a free, open-source application. The code can be downloaded from Google Code.

Hi Christian,Thanks for the tutorial, this is an ace new feature!I’ve noticed that if you have multiple NativeWindow instances running as part of an Application and listen for the ‘StorageVolumeChangeEvent.STORAGE_VOLUME_MOUNT’ event then it is fired for each active NativeWindow. Is this a bug or is this the way this system was meant to work? I can manually check for multiple calls by storing references to the drive name I guess but it seems a bit hacky? How would you go about this?ThanksTom
I am getting this prompt for my flex builder 31046: Type was not found or was not a compile-time constant: StorageVolumeChangeEvent.So missing libraries?
I run into same type of issues while compiling FileTile.mxmlFileTile.mxml(98): Error: Type was not found or was not a compile-time constant: StorageVolumeChangeEvent.In case it might help, I’m using the milestone release build flex_sdk_4.0.0.10485 on Ubuntu Linux.
I had the similar problem while compiling FileTile sample application.The problem was solved by grabbing the latest nightly build of Gumbo Flex SDK (v4.1.0.14345) from http://opensource.adobe.com/wiki/display/flexsdk/download?build=4.1.0.14345&pkgtype=1
Any method for unmounting the drive from within AIR? Mac pop up an ugly error if you don’t unmount your drive first, and people won’t have access to the to the finder from a kiosk i am working on. Most likely the Kiosk will be on Windows, however would like to have it work on mac just in case.
This looks like it’s Flex.
Can you write the same using JavaScript and HTML?
Yes:
could look like this
var StorageVolumeInfo = window.runtime.flash.filesystem.StorageVolumeInfo.storageVolumeInfo;
var USBstorage = new USBstorage();
StorageVolumeInfo.addEventListener(window.runtime.flash.events.StorageVolumeChangeEvent.STORAGE_VOLUME_MOUNT, onVolumeMount);
StorageVolumeInfo.addEventListener(window.runtime.flash.events.StorageVolumeChangeEvent.STORAGE_VOLUME_UNMOUNT, onVolumeUnmount);
I think you should include ” the aircore.swf in your air application to use the window.runtime methods.
I created the AIR 2 application in Flash Builder and installed .AIR o/p into USB drive as .exe. When I run the application from USB drive, I want to see the USB information on which application resides. Can you suggest somethng?