Skip to content
Aug 27 2009 / alecmce

Vector.unshift Gotcha (for the time-being)

I didn’t see this coming:

var list:Vector.<MockObject> = new Vector.<MockObject>();

var a:MockObject = new MockObject("a");
var b:MockObject = new MockObject("b");
var c:MockObject = new MockObject("c");

list.push(a);
trace(list);			// outputs "a"

list.push(b);
trace(list);			// outputs "a,b"

list.unshift(c);
trace(list);			// outputs "c,a"

No, I haven’t made a mistake. It’s a bug! The Flash 10 Language Reference explicitly says that this isn’t supposed to happen. After a little searching, Adobe JIRA affirms that this bug is known, and fixed – well fixed in the ‘Future – Next Build’ release.

I really hate wasting two hours of my time to discover that my test case is failing because the Flash Player is itself broken, and not because I’m an idiot. Clearly, Adobe don’t unit test. As ever, I am really glad that I do!

  • http://twitter.com/alecmce alecmce

    Vector.unshift is broken! Why Adobe, why? http://bit.ly/Wrx9P #as3
    This comment was originally posted on Twitter

  • Bart

    Thanks man, this showed up in google way before the Jira. I spend an hour before I got it isolated to the broken unshift (not something you’d assume to be broken). Anger is being made but not sense :-)