Wow, this AIR stuff really works

Submitted by Falken on Sun, 05/11/2008 - 10:40

(yes, another AIR success story, but it's mine :-) )
My wife and I are lucky enough to get the same train in and out of the city, and it was on the journey home on Friday that she mentioned some work flow changes in her office. The upshot of these changes was that she was having to look at raw XML files many times a day.

I foolishly mentioned I could probably knock something up 'in a few hours' to make this a lot easier.And I could !
It was relatively trivial to get all the 'hard' stuff working - being able to just drag an XML file on to the application, for instance, was just a matter of following the LiveDocs. The same went for reading the dropped file into an XML instance to parse using E4X.

I seems hardly worth mentioning the fact that I developed it on Linux, but it's deployed to her Windows laptop, but that's always been one of the big selling points. And I knew technically it should work, but it was still fun seeing her run the .air file and it all just working.

No, you can't have the source. No, you can't have the binary.
It appears to parse a propiatary XML schema rather than, say, BizXML so it wouldn't be much use to you (as I can't give you the XML file it parses), sorry.

Instead, here's a screen shot and the key lines of code to take a dropped XML FIleReference and turn it into an XML object.

private function onDragDrop( event:NativeDragEvent ) :void{
var files:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
for each (var f:File in files){
parseFile( f );

private function parseFile( f:File):void{
var data:FileStream=new FileStream();,FileMode.READ);
var str:String= data.readUTFBytes(data.bytesAvailable);
var xml:XML=new XML(str);