From d426b70e587ab69efbda907b74ab65308a2d17db Mon Sep 17 00:00:00 2001 From: Tom Conkling Date: Thu, 19 Jun 2008 20:18:24 +0000 Subject: [PATCH] This is probably not such a good idea after all git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@547 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/DisplayUtil.as | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/as/com/threerings/flash/DisplayUtil.as b/src/as/com/threerings/flash/DisplayUtil.as index 3f06d1c7..0aafbe8c 100644 --- a/src/as/com/threerings/flash/DisplayUtil.as +++ b/src/as/com/threerings/flash/DisplayUtil.as @@ -43,30 +43,22 @@ public class DisplayUtil container :DisplayObjectContainer, comp :Function = null) :void { var numChildren :int = container.numChildren; - - // since it's likely this function will be called frequently on the same - // DisplayObjectContainer, keep the Array around so that we're not - // re-allocating memory more often than we need to - if (_sortDisplayChildrenArray.length != numChildren) { - _sortDisplayChildrenArray = new Array(numChildren); - } - + // put all children in an array + var children :Array = new Array(numChildren); var ii :int; for (ii = 0; ii < numChildren; ii++) { - _sortDisplayChildrenArray[ii] = container.getChildAt(ii); + children[ii] = container.getChildAt(ii); } // stable sort the array - ArrayUtil.stableSort(_sortDisplayChildrenArray, comp); + ArrayUtil.stableSort(children, comp); // set their new indexes for (ii = 0; ii < numChildren; ii++) { - container.setChildIndex(DisplayObject(_sortDisplayChildrenArray[ii]), ii); + container.setChildIndex(DisplayObject(children[ii]), ii); } } - private static var _sortDisplayChildrenArray :Array = []; - /** * Call the specified function for the display object and all descendants. *