Archive of January 2010

another AS3 annoyance

XMLLists. What the fuck: from the documentation,

The XMLList class contains methods for working with one or more XML elements. An XMLList object can represent one or more XML objects or elements (including multiple nodes or attributes), so you can call methods on the elements as a group or on the individual elements in the collection.

If an XMLList object has only one XML element, you can use the XML class methods on the XMLList object directly. In the following example, example.two is an XMLList object of length 1, so you can call any XML method on it.

Which is great, if I don't care about properly typing my variables.

TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@1f51a779 to XML.

And of course there's no builtin way to convert a length-of-one XMLList into a normal XML object. Have to resort to the ugly (but simple)

var xml:XML = new XML(bullshitXMLList.toXMLString());

And really. Why wouldn't XMLList inherit from XML? Seriously?

Fuck AS3.

It supports associative arrays, which is great, but they're broken: the length of an associative array is 0. This is because, as far as I can see, length is just a normal property that's updated when you call foo[n]. But it's just fucking ignored if you call foo[string].

Hell, the documentation even says as much, but seriously?

There is no advantage in using the Array constructor to create an associative array. You cannot use the Array.length property or any of the methods of the Array class with associative arrays, even if you use the Array constructor or the Array data type. The use of the Array constructor is best left for the creation of indexed arrays.

Why even write that? As soon as the words hit the screen, you'd think someone would say, "this is bullshit. what the fuck were we thinking?" and file a bug. There's even a stack overflow thread on how to find the length of an associative array. How is this not built in?