Fast Z-Sorting in Flash 10

Finally got round to taking a look at doign some Z-Sorting in Flash 10, the old try to find a faster way then Array.sortOn( "z" , Array.NUMERIC ); method that everybodies coined the "king of speed" but is still a bit slow!

So.. here it is, one line, using Vector instead of Array, and twice as fast (on my machine anyways) - with the source of course.

important: turns it this runs slower if the z-val is outside of the range 0-1; a LOT slower, so don't use!

Fast Flash Z-Sorting with Vectors

z-sort

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Printed from: http://webr3.org/blog/flash-10/fast-z-sorting-in-flash-10/ .
© Your Name Here 2012.

1 Other Comment

3 Comments   »

  • Elliot Rock says:

    spelling mistake mate "doign" must be the CO2!

  • Ha, you had me there for a second, wondering and staring my screen, since my benches had said something else about this.

    It's about the testing data. For this test, the compare function works. But, if your values go beyond the range of 0-1, you'll find that Array wins hands down by a big length. Try and fill your values with -100 to 100, for instance. I'm not sure what's wrong here. The comparison function description in the as3 docs says it should be positive, 0 or negative. But the magnitude of that number in positive and negative direction greatly affects the speed. I guess it makes sense, since it's used to index the value, but it's odd this is the case now.

  • nathan says:

    you're right! strange too.

    2 bugs:
    a - should be y.z - x.z for descending order
    b - any z val outside of the range 0-1 makes it run like a dog

    back to the drawing board!

RSS feed for comments on this post , TrackBack URI

Leave a Reply

Additional comments powered by BackType

  • webr3 avatar