diff --git a/src/as/com/threerings/crowd/client/PlaceViewUtil.as b/src/as/com/threerings/crowd/client/PlaceViewUtil.as index 8b36177e3..1c239c49f 100644 --- a/src/as/com/threerings/crowd/client/PlaceViewUtil.as +++ b/src/as/com/threerings/crowd/client/PlaceViewUtil.as @@ -23,7 +23,7 @@ package com.threerings.crowd.client { import flash.display.DisplayObject; -import mx.utils.DisplayUtil; +import com.threerings.util.DisplayUtil; import com.threerings.crowd.data.PlaceObject; @@ -72,7 +72,7 @@ public class PlaceViewUtil return; } - DisplayUtil.walkDisplayObjects(root as DisplayObject, + DisplayUtil.applyToHierarchy(root as DisplayObject, function (disp :DisplayObject) :void { if (disp is PlaceView) { try { diff --git a/src/as/com/threerings/util/DisplayUtil.as b/src/as/com/threerings/util/DisplayUtil.as index 7507410eb..700d4e6f9 100644 --- a/src/as/com/threerings/util/DisplayUtil.as +++ b/src/as/com/threerings/util/DisplayUtil.as @@ -1,10 +1,45 @@ package com.threerings.util { +import flash.display.DisplayObject; +import flash.display.DisplayObjectContainer; + import flash.geom.Point; import flash.geom.Rectangle; +import mx.core.IChildList; +import mx.core.IRawChildrenContainer; + public class DisplayUtil { + /** + * Call the specified function for the display object and all descendants. + * + * This is nearly exactly like mx.utils.DisplayUtil.walkDisplayObjects, + * except this method copes with security errors when examining a child. + */ + public static function applyToHierarchy ( + disp :DisplayObject, callbackFunction :Function) :void + { + callbackFunction(disp); + + if (disp is DisplayObjectContainer) { + // a little type-unsafety so that we don't have to write two blocks + var o :Object = (disp is IRawChildrenContainer) ? + IRawChildrenContainer(disp).rawChildren : disp; + var nn :int = int(o.numChildren); + for (var ii :int = 0; ii < nn; ii++) { + try { + disp = DisplayObject(o.getChildAt(ii)); + } catch (err :SecurityError) { + continue; + } + // and then we apply outside of the try/catch block so that + // we don't hide errors thrown by the callbackFunction. + applyToHierarchy(disp, callbackFunction); + } + } + } + /** * Returns the most reasonable position for the specified rectangle to * be placed at so as to maximize its containment by the specified