开发者

get position of instance of the same type in the stage

hi i'd like to count and get position of instance of the same type in the stage. i have tried:

var target; 
for(var item in _root){     
if(_root[item] instanceof MovieClip ||   _root开发者_StackOverflow社区[item] instanceof TextField){         
target = _root[item];         
trace("ITEM: "+target);         
trace("X: "+target._x);         
trace("Y: "+target._y);         
trace("----------------");     } }

but it says access to property _root undefined, and instanceof deprecated how can i make it? thanks


in as3 you can loop through all children of your stage (or parent movieclip):

for (var i : int = 0;i < stage.numChildren;i++) 
{
    var displayObject : DisplayObject = stage.getChildAt(i);
    if(displayObject is TextField || displayObject is MovieClip)
    {
        trace("ITEM: " + displayObject);         
        trace("X: " + displayObject.x);         
        trace("Y: " + displayObject.y);         
        trace("----------------");
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜