Sunday 14 August 2011

Quick Tip: Checking for XML nodes with a namespace

This is a small follow up to Common Mistakes: XML Namespaces and E4X: when working with namespaces, calling hasOwnProperty() may not work as expected. Consider the following example:

var xml: XML = <root xmlns:space="http://www.something.com">
 <space:tag>
  <node>Hello, world!</node>
 </space:tag>
</root>;

trace( xml.hasOwnProperty( "tag" ) );

In this case, hasOwnProperty() will return false as the 'tag' tag is part of the 'space' namespace. In order to overcome this, use the QName construct, e.g.:

xml.hasOwnProperty( new QName( "http://www.something.com", "tag" ) )

Alternatively, if you have declared a namespace previously, you can do the following:

namespace space = "http://www.something.com"; 

// ...

xml.hasOwnProperty( new QName( space, "tag" ) )

Thursday 11 August 2011

Quick Tip: FlashBuilder 4.5 Premium Upgrade Download

Just a really quick one: Adobe's consumer site (in Australia, at least) does not have the option to allow the FlashBuilder 4 Premium to FlashBuilder 4.5 Premium Upgrade to be purchased as a download - it's only available as a shipped box. if you need it quicker than that, the solution is to purchase it from the Adobe Business site instead: http://volumelicensing.adobe.com/AU Note that a serial and download link is not provided immediately; after roughly 24 hours you will receive access to the Adobe Volume Licensing site where you can access these details.