Thursday, January 31, 2008

ActionScript function to convert XML into Array

To allow the grouping and summary rows in DataGrid, I decided to convert existing report (old fashion DataGrid) to AdvancedDataGrid, which is a new feature of Flex 3. And which is turned out that raw XML I receive from backend returns an error. I needed more control of the data. As a part of the fix I wrote the conversion function which returns associated array collection based on input xml. Enjoy:


private function xml2array(xml:XMLDocument):ArrayCollection {
var ac:ArrayCollection = new ArrayCollection();
var xmlNodes:ArrayCollection = new ArrayCollection(xml.childNodes);
for (var i:int = 0; i < xmlNodes.length; i++) {
var thisRecord:Dictionary = new Dictionary();
var rowObj:Object = xmlNodes[i].childNodes;
for (var j:int = 0; j < rowObj.length; j++) {
var thisNodeName:String = rowObj[j].localName;
var thisNodeValue:String = '';
if (rowObj[j].childNodes && rowObj[j].childNodes.length > 0) {
if (rowObj[j].childNodes[0].nodeValue)
thisNodeValue = rowObj[j].childNodes[0].nodeValue;
else
thisNodeValue = '';
}
thisRecord[thisNodeName] = thisNodeValue;
}
ac.addItem(thisRecord);
}
return ac;
}

Wednesday, January 23, 2008

Silicon Valley Flex User Group meeting

Last night I gave Ebay a visit and attended the Silicon Valley Flex User Group meeting held by http://www.silvafug.org/, and here are some highlights which took my attention.


First of all, we were provided with wi-fi, which was pretty convenient. But I was surprised how EbayGuest wi-fi account blocks Skype, the Ebay’s communicator application.

Main speaker was Ted Patrick, Flex Evangelist from Adobe. There were about 100 people. Primarily developers. Many people from Ebay and Yahoo (they have flash development group which develops flash components used within the yahoo), a lot of new startups who either have chosen flex and want to make sure they did a right choice or who is in evaluating stage. Many of them are hiring, or looking for partners. Couple designers, and even HR person.

And first of all, Flex 3 final will be released in 5 weeks from today!

Ted made an overview of Flex 3 features, and mentioned Flex 4 couple times. Personally, majority of information I knew already as it was discussed on MAX 2007 in Chicago.

In brief:

Flex 3 will be open source on Mozilla license, all of byte code, compiler, all of it. As before, SDK download and use is free. Flex Builder 3 Pro which includes charts and automated testing framework will cost $649.

AMF format – serialized ActionScript object. As written here: http://www.onflex.org/ted/2007/11/abcs-of-amf.php : "It is an ideal way to exchange data and persist objects to disk or to the network". There is a variety of implementations: AMF-PHP, OpenAMF…

New features of design mode in Flex Builder 3:

New Pan and Zoom tools, and Constrain-based layout development.

There is skin import wizard, and vision that designers can work separately from developers. Art designer is just updating new skin created, for example in Illustrator, in to versio control system. And BTW Flex works well with any popular version control system. For skins, there is very good resource: www.scale9.com. They have WinXP, MacOS and a wide variety of skins to completely change the look of the applications in minutes. My opinion: we have to support skinning. I think we can have one general Packeteer company-wide [EK: company I work for] skin, which will cover all Felx display object types. Then we can create sub-skins, like IntelligentServices, iShaper, PacketShaper [EK: line of Packeteer's products] and so on. These skins will be created in Flash CS3 or Illustrator CS3.

Ability to embed OpenType fonts (fonts which may be very complex, arty crafty and not be installed on the client machine) in Flex application, in addition to the use of commonly found fonts like Verdana.

Advanced DataGrid with example of “Total:” row which is a floating row summarizing above values, new tree objects, and advanced sorting functionality. It is useful in reports, and I think to use it in admin account reports in one of my applications.

Ted talked also about AIR, mentioned that Flex has built-in web browser, based on the same open source code which is used in iPhone and Safary: http://webkit.org/; and ability to render html pages.

AIR is an architecture to create and run desktop applications on the computers with Flash Player (7 and up) installed, supports Mac and Win, will Linux (in couple weeks they will announce this).

AIR app has an auto-update feature. User doesn’t need to go to remote url and take care of being up-to-date. Also, small but convenient feature: Flash app badge installer. All of this is aimed to smooth all issues related to application install process.

Overall: Flex platform appeared to be more successful than Adobe predicted in the beginning. 99% of all today’s computers in the world have Flash Player installed. There are billions of installs, as well as growing number of Flex projects and developers involved.