E4X: A better way to deal with XML.
I’m not writing anything that hasn’t already been documented out there before, but I did want to mention one of my favorite things about AS3 - E4X. E4X is ECMAScript for XML. You can read more about it here. http://en.wikipedia.org/wiki/E4X.
XML is implemented natively into ActionScript 3… no more parsing XML files form astrong. You can leverage this to traverse XML files for specific pieces of content without the need of running a for loop or converting the XML to an object or anything. The trick is mastering the syntax.
Daniel got me started on it, but here’s a great tutorial on E4x that I highly recommend to learn and experiment with. http://www.partlyhuman.com/blog/roger/as3-e4x-rundown
E4X can look pretty advanced at times… Stephen and I got a good laugh out of this line that I wrote yesterday:
return Constants.CONFIG.scenes.*.child(__BASESCENE).scene.(@id == $scene_id)[0].parent();
But it’s really not all that bad. And way better than the old firstChild.childNode.childNodes of yore.
April 23rd, 2008 by Jamie / 5 Commentsactionscript, flash




