flex error 1180: Call to a possibly undefined method SortField.

Here I was, following a very nice tutorial showing you how to use an XMLListCollection with a nice example with source view enabled (thank you Bruce Phillips, btw!) when suddenly flexbuilder starts to complain about error 1180 : Call to a possibly undefined method Sortfield.

Even when the sortfield function is right there in the same function !?

It turns out, after quite a bit of googling around finding not very much, that flexbuilder for once did *not* automagically write the import statement for the sortfield. It did so for the sort function, but not for the sortfield function. I don’t know if this only happened to me or if this is so all the time.

But here, the advantage of working with flexbuilder turned to a disadvantage – I expected it to add the import statement necessary for it all by itself; for once, it did not do it.

All I needed to do was to add theĀ  import mx.collections.SortField; to get things working again. Still, I lost some programming time looking for a solution to this problem, so I’m blogging this in case you have a similar experience.