开发者

AS3 - Get MovieClip instance name onClick

开发者 https://www.devze.com 2023-03-18 07:03 出处:网络
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?

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

精彩评论

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