Posts

Showing posts from 2008

callLater() and ObjectUtil.toString()

Couple useful Flex methods for the reference: If you want to print out all properties of the object, i.e. see comprehensive string representation of any object, use the following example: Alert.show("IOError: " + mx.utils.ObjectUtil.toString(event)); Another useful method is callLater() The callLater() queues an operation to be performed for the next screen refresh, rather than in the current update. Without the callLater(), you might try to access a property of a component that is not yet available.

AIR: Get filtered list of files from filesystem

Task definition: Get list of files from specified location on the desktop or on the web which mathc certain filename pattern. In case of web you have to provide mechanism using HTTPService object. This example demonstrates AIR (desktop) version. import flash.filesystem.File; /** File in format: 4 to 8 digits of the name and 2 digits of the extension */ private var diagFilenamePattern:RegExp = /\d{4,8}\.\d{2,2}/g; public function init():void { var fileName:String = ''; var diagDir:File = new File(); diagDir.nativePath = "C:\\projects\\test_data"; // change to your directory var origDiagFiles:Array = diagDir.getDirectoryListing(); var filteredDiagFiles:Array = new Array(); for each (var file:File in origDiagFiles) { fileName = file.nativePath; fileName = fileName.substring( fileName.lastIndexOf(File.separator)+1, fileName.length); trace(fileName); if (fileName.match(diagFilenamePattern).length) { // check if pattern match filteredDiagFiles.push(file); ...

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) ...

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 kn...