Flex 3 Actionscript Examples

Thursday, July 17th, 2008

I was reading some Flex docs online the other night, and in the live docs section I noticed a link to where you could download the example scripts for many of the examples shown in the Flex docs.  The zip file is available here and contains some great Flex/AS projects including a Wiki Editor, Video Jukebox, Display Object Transformer and many more.

Google Maps API for Flash/Flex

Thursday, May 15th, 2008

Google has just announced the Google Maps API for Flash.  This AS3 library will allow you to natively put Google Maps into your Flex or Flash apps without having to do any hacky-hack iFrame/div methods.  You can read the announcement on Google’s blog.

Flex SDK Coding Conventions

Friday, April 18th, 2008

The OpenSource Flex site has released the team’s Flex SDK coding conventions and best practices.  If you’re planning on committing code to the SDK, these are the guidelines that you will have to follow.  These guidelines are also useful even if you’re just looking to be a better AS3 coder.

E4X Selection by Attribute in Flex

Sunday, November 18th, 2007

My colleague David Meeuwis showed me a most useful and non-intuitive tip that explains a subtle difference between using the @ axis and the attribute() axis in E4X. For example, given the following XML fragment…


<names>
<name salutation="Mr">Billy Bob Thorton</name>
<name salutation="Mrs">Angelina Jollie</name>
<name>Brad Pitt</name>
<name salutation="Ms">Jennifer Aniston</name>
<name salutation="Mr">Vince Vaugn</name>
</names>

The AS3 expression below…

myXml.name.(@salutation == 'Mr')

…will find all the names that have a salutation attribute equal to ‘Mr’. However, if there is any name in the xml that doesn’t have a salutation attribute, that query will throw an exception and die. However…

myXml.name.(attribute('salutation') == 'Mr')

Will give back all names that have a salutation attribute equal to ‘Mr’ and ignore any name elements without a salutation attribute.

So unless you are absolutely positive that the attribute you are selecting always exists, you should be using the attribute() axis over the @ axis.

Here is a quick Flex example with view source enabled that you can test with.