简体   繁体   English

Flash检测单击的影片剪辑的数组索引

[英]Flash detect array index of clicked movie clip

I have an array of movieclip class and give it clickHandler to detect mouse click on my movieclip. 我有一个movieclip类的数组,并将其设置为clickHandler来检测对我的movieclip的鼠标单击。

var _drone:Array = new Array();
for(var i:int = 0;i<25;i++)
{
    _drone[i] = new drone();
    _drone[i].y = (Math.random()*-1000)+35;
    _drone[i].x = (Math.random()*400)+35;   
    _drone[i].addEventListener(MouseEvent.CLICK, clickHandler);
    _drone[i].stop();       
    addChild(_drone[i]);
}

function clickHandler (event:MouseEvent):void {
    //start animation
}

My problem is I don't know how to detect which drone I'm clicking to start the animation. 我的问题是我不知道如何检测要单击的无人机以开始动画。 Can someone help? 有人可以帮忙吗?

function clickHandler (event:MouseEvent):void {
    //start animation
    event.currentTarget.play();
}

See documentation . 请参阅文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM