Implemented DisplayUtil.applyToHierarchy, because the similar function
included in the mx library is unable to cope with security errors accessing a child. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4444 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -23,7 +23,7 @@ package com.threerings.crowd.client {
|
|||||||
|
|
||||||
import flash.display.DisplayObject;
|
import flash.display.DisplayObject;
|
||||||
|
|
||||||
import mx.utils.DisplayUtil;
|
import com.threerings.util.DisplayUtil;
|
||||||
|
|
||||||
import com.threerings.crowd.data.PlaceObject;
|
import com.threerings.crowd.data.PlaceObject;
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ public class PlaceViewUtil
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayUtil.walkDisplayObjects(root as DisplayObject,
|
DisplayUtil.applyToHierarchy(root as DisplayObject,
|
||||||
function (disp :DisplayObject) :void {
|
function (disp :DisplayObject) :void {
|
||||||
if (disp is PlaceView) {
|
if (disp is PlaceView) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,10 +1,45 @@
|
|||||||
package com.threerings.util {
|
package com.threerings.util {
|
||||||
|
|
||||||
|
import flash.display.DisplayObject;
|
||||||
|
import flash.display.DisplayObjectContainer;
|
||||||
|
|
||||||
import flash.geom.Point;
|
import flash.geom.Point;
|
||||||
import flash.geom.Rectangle;
|
import flash.geom.Rectangle;
|
||||||
|
|
||||||
|
import mx.core.IChildList;
|
||||||
|
import mx.core.IRawChildrenContainer;
|
||||||
|
|
||||||
public class DisplayUtil
|
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
|
* Returns the most reasonable position for the specified rectangle to
|
||||||
* be placed at so as to maximize its containment by the specified
|
* be placed at so as to maximize its containment by the specified
|
||||||
|
|||||||
Reference in New Issue
Block a user