I stumbled on this simple and interesting bug with the List component in Flex: Adding an item with a label of “toString” to a List component will break the List, and take down much of your application with it. Just add the following to a new or existing mxml app (tested in Flex 2.0.1):
<mx:List dataProvider=”[‘toString’]”/>
I find this bug interesting because despite thinking it over last night (when I should have been sleeping), I still can’t think of a good reason for why it occurs. The obvious culprit is the correlation between the string value, and List calling toString to get the label, and this somehow causes a conflict. I can’t think of a scenario where this would cause an issue though – calling toString on a string will merely return the string value, regardless of what that value is. I even tested (amongst other things) calling toString on a “toString” String (wow, convoluted) to ensure this wasn’t a deeper player level bug.
I haven’t had time to track down the cause in the framework yet, but I plan to soon. It’s bugging me, because I can’t see why there would be any correlation between this specific value of the label, and the rendering of the list item. I also have a programmer’s natural aversion to edge cases (what if my user adds an item named “toString”, and my whole app blows up?).
Hopefully there will be more, in-depth blog entries to come in the not too distant future. There’s been a lot of interesting stuff going on here at gskinner.com, including our work developing the v3 components set, continued work on our computer vision software, and our expansion into doing Flex work, which I’d love to blog about. Alas, my time is very short at the moment, between work, conferences, traveling, and building a new house (originally designed in Flash, though that’s a story for another entry).