本文介绍了MC的子节点上的hitTestObject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为playerP的MC,里面有7个不同的MC,我似乎无法测试孩子MC,总是显示[object position_2]

  private function cMove(e:MouseEvent):void 
{
trace(MovieClip(playerP.RR),playerP.PT)
if(e.currentTarget.hitTestObject(playerP.PT))
{
trace(hit la);
}
}


解决方案



<$私人函数cMove(e:MouseEvent):void
{
for(var ii:uint = 0; ii< playerP.numChildren; ++ ii)$ (e.currentTarget.hitTestObject(playerP.getChildAt(ii)))
{
trace(hit la);
}
}
}


I have a MC called 'playerP" and inside of it with 7 different MC. I can't seems to hit test on the children MC, it always show [object position_2]

private function cMove(e:MouseEvent):void
        {
            trace(MovieClip(playerP.RR), playerP.PT)
            if (e.currentTarget.hitTestObject(playerP.PT))
            {
                trace("hit la");
            }
        }
解决方案

Try explicitly iterating through the children.

private function cMove(e:MouseEvent):void
    {
        for (var ii : uint = 0; ii < playerP.numChildren; ++ii)
        {
            if (e.currentTarget.hitTestObject(playerP.getChildAt(ii)))
            {
                trace("hit la");
            }
        }
    }

这篇关于MC的子节点上的hitTestObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 06:57