开发者

AS3 - Get MovieClip instance name onClick

I've a row of MovieClips with开发者_C百科 the instance names holder0 to holder7. How can I get the holder name of the MovieClip by click?

Thanks for tips.


Something like this:

var mc:MovieClip;
for (var i:int = 0; i<8; i++) {
    mc = this["holder"+i];
    mc.buttonMode = true;
    mc.mouseChildren = false;
    mc.addEventListener(MouseEvent.CLICK, clickHandler);
}

function clickHandler(e:MouseEvent):void {
    trace(e.target.name);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜