Posts

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

Adobe MAX 2007 conference: visitor notes

I have to admit that these four thousand people at the conference in majority were very enthusiastic, showed a lot of interest and eager to learn and to be at the top of the technological edge. Adobe gathered a lot of companies and individuals who combined various production line ideas and tricks in attempt to create something new. And many of them succeed. No doubt there was what to see and what to do. My prime interest was Flex and ActionScript 3.0. Accordingly I attended sessions related to these technologies. Here at glance some thoughts and ideas which caught my attention during sessions: In Customizing the Flex Framework session: Skinning, effects, data descriptors, collections, validators, formatters can be extended to implement our own components. Speaker pointed the use of tag which adds a new scope of content, and if we want to access outer scope from our component, we use 'outerDocument'. In case of bug in Flex framework impossible to find a workaround for we can ...

Mainstream is Flex 2. Today.

Ok. It's been a while I have not posted here. The main reason is I am not THAT interested in DHTML these days since I joined Packeteer . I immediately started to learn and develop on Adobe Flex 2 and Apollo (which is called AIR now). For the last three months I've learned many tricks how to make actual application work, how to build web site on it, and make it dynamic. Just want let you know I am here, not actually looking for another job, and probably will start postings about Flex, because it is really COOL. Cheers.

Add zero-width spaces every 10 characters

For dynamic pages sometimes you can't say in advance what exact content will be, and therefor you have no control of actual content, for example words can be very long, and not wrappable by browser. For this purposes I use special zero-width space (x200B) which exists in HTML specs. I wrote a function which you call on strings whenever you need it: yourStr.HTMLwrap() Here it is: /** Add zero-width spaces every 10 characters */ String.prototype.HTMLwrap = function() { var i = 0; var a = ''; var len = this.length; while(len > i*10+10) { a += this.substr(i*10, 10) + '\u200B' i++; } return a + (i>0?this.substring(i*10, this.length):this); }

How to test javascript performance time

First, create area where results will be output. You can adjust any style property to fit your needs. Minimum what you need to change is "parentNodeId": // Test env function testEnv() {  var parentNode = document.getElementById("parentNodeId");  if (parentNode) {   var testNode = document.createElement("div");   testNode.id = "testEnv";   testNode.style.height = "7em";   testNode.style.backgroundColor = "white";   testNode.style.overflow = "auto";   testNode.style.border = "1px solid #778899";   testNode.style.textAlign = "left";   testNode.style.overflowX = "hidden";   testNode.style.whiteSpace = "nowrap";   parentNode.appendChild(testNode);  } } Then, in the function or any piece of the code you are testing, write: in the beginning: var beginTime = new Date().valueOf(); and finally, at the end: if (document.getElementById("testEnv"))   document.getElementById("...