Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含多个具有相同名称的对象的影片剪辑,我想访问具有特定名称的最上面的孩子 - 我将如何处理?我知道
mc.getChildByName('theName')
返回该名称的第一个孩子,但我实际上需要获得最高的孩子。
一种方法是:
function getTopChild(targetMC, childName:String):MovieClip { for (var index:int = targetMC.numChildren-1;index >= 0;index--) { var child:MovieClip = targetMC.getChildAt(index) as MovieClip; if (child.name == childName) { return child; } } return null; }