我正在尝试创建多个addEventListener,但我不知道如何。正如你在下面的代码中看到的那样 - 我不明白我写的地方需要写什么????????为了产生多个功能(例如onClick1,onClick2,onClick3等......)
for (i=0; i < numberOfResults; i++)
{
videoResults[i] = new Object();
videoResults[i].movie = new MovieClip();
stage.addChild(videoResults[i].movie);
videoResults[i].movie.addEventListener("click",?????????);
function ?????????(event)
{
}
}
我需要做什么?
答案 0 :(得分:2)
您不想在for循环中编写函数。做这样的事情:
for (i=0; i < numberOfResults; i++)
{
videoResults[i] = new Object();
videoResults[i].movie = new MovieClip();
stage.addChild(videoResults[i].movie);
videoResults[i].movie.addEventListener(MouseEvent.MOUSE_DOWN, myMadeUpCallbackEvent);
}
function myMadeUpCallbackEvent(evt:MouseEvent):void
{
//In order to be able to tell which clip has called this callback, you can compare the properties of evt.currentTarget. The evt is the Event object cast into a reference. evt.currentTarget is the target or object that called the event. So you can do something like this:
trace(MovieClip(evt.currentTarget).name); to get the unique name of the caller
}
您可能对Flash上的免费视频教程网站感兴趣: