[Component] Location WatchDog v1.0

It’s been a long time since I posted in my blog. The reason was that I wasn’t actually working actively on any Flex project in my previous job at Nokia. In my new role, I hope to get lots of chances to dabble with my favorite coding language 😉 . Anyway, here I am with a new simple and silly component again 🙂

I am calling it a Location WatchDog. What it does is pretty simple. It monitors a specific location (folder/directory) for any updates. If any new files are added to the folder, the WatchDog throws an event LocationEvent.FILES_ADDED. The event returns an array of new Files added to the location.

I am still working on it. Need to add some more stuff to it like capability to fire the LocationEvent.FILES_DELETED that returns the list of deleted files. The component allows you to also specify file extensions that you wish to monitor the location for. By default the component only detects normal files, while it also allows you to specify includeSystemFiles attribute as true to force the component to listen to even hidden and system files.

You can download the component in swc from here. The code of the component is checked in at the Google Code.

You can use this component in your code by calling the component in your mxml  – and then doing this in your actionscript-

private function initView():void{
snoopy.fileExtensions = <code>new Array("txt", "abc");</code>
<code>snoopy.locationPath = File.desktopDirectory.nativePath;
snoopy.addEventListener(LocationEvent.FILES_ADDED, getNewFiles);
snoopy.startPinging();
}

private function getNewFiles(event:LocationEvent):void{
var x:Object = event;
}

Nothing fancy. Just simple and plain. As long as it saves someone somewhere some coding time ;). Or is it already part of the framework? 😉

(Download: SWC | Source)

Advertisements

CForm SWC

Lately I have been getting a lot of mails about using CForm. So, I kind of wrapped up the whole thing into a SWC and here it is. So all you need to do is download this and add this to the Lib of your project. For the source code, you can still check it out of SVN. But, to just use the CForm, you really do not need the source-code, you can just use this swc component. Click here to download the component.