开发者

hitTestObject on child of a MC

开发者 https://www.devze.com 2023-02-04 18:36 出处:网络
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]

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");
            }
        }


I am trying to reference a movieclip that has 2 layers and 2 instance references. One is called Erik, the other hit. Currently the larger Erik is working, how can I make 'hit' be the target.

for (var ii : uint = 0; ii < target.numChildren; ++ii) {
    if (e.currentTarget.hitTestObject(target.getChildAt(ii))){
        trace("hit la");
    }
}

This works but on Erik which is set by

public function Catcher(stageRef:Stage, target:Erik) : void

as Erik is a class object.


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");
            }
        }
    }
0

精彩评论

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

关注公众号