Because of the namespaces things don't work when copy pasting from the documentation from AS3.
photography by Kristel van Beek
posted by: martijn, at 17 August 2007 12:39 GMT+1, 24 October 2009 12:21 GMT+1
Because of the namespaces things don't work when copy pasting from the documentation from AS3.
var data:XML = <sa:photos> <sa:photo src="left.jpg"/> <sa:photo src="right.jpg"/> </sa:photos>
The compiler throws the following error: The prefix "sa" for element "sa:photos" is not bound.
You have to define it like:
var data:XML = <sa:photos xmlns:sa="uri of namespace"> <sa:photo src="left.jpg"/> <sa:photo src="right.jpg"/> </sa:photos>
Maybe this sounds logical now but the documentation is not so clear about this.
When added a node to this object you could do it like:
var x:XML = <sa:photo src="filename" /> data.appendChild(x);
But the same error is thrown, you have to do it like:
var x:XML = <sa:photo src="filename" xmlns:sa="uri of namespace" /> data.appendChild(x);