Return to Snippet

Revision: 13977
at May 14, 2009 10:12 by sidneydekoning


Initial Code
// Download Volume Monitor in Adobe's coreLib from http://code.google.com/p/as3corelib/

import com.adobe.air.filesystem.FileMonitor;
import flash.filesystem.File;
import flash.events.Event;
import com.adobe.air.filesystem.events.FileMonitorEvent;

private var monitor:FileMonitor;

private function onSelectButtonClick():void
{
	var f:File = File.desktopDirectory;
	f.addEventListener(Event.SELECT, onFileSelect);
	f.browseForOpen("Select a File to Watch.");
}

private function onFileSelect(e:Event):void
{
	var file:File = File(e.target);

	if(!monitor)
	{
		monitor = new FileMonitor();
		monitor.addEventListener(FileMonitorEvent.CHANGE, onFileChange);
		monitor.addEventListener(FileMonitorEvent.MOVE, onFileMove);
		monitor.addEventListener(FileMonitorEvent.CREATE, onFileCreate);
	}

	monitor.file = file;
	monitor.watch();
}

private function onFileChange(e:FileMonitorEvent):void
{
	trace("file was changed");
}

private function onFileMove(e:FileMonitorEvent):void
{
	trace("file was moved");
}

private function onFileCreate(e:FileMonitorEvent):void
{
	trace("file was created");
}

Initial URL

                                

Initial Description

                                

Initial Title
USB Support in AIR

Initial Tags

                                

Initial Language
ActionScript 3