/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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"); }