Flash as3“尝试添加多个”;onClick";事件-我如何做到这一点?
我正在尝试创建多个addEventListener,但不知道如何创建。正如你在下面的代码中所看到的,我不明白我需要在我写的地方写些什么????????为了产生多个功能(如onClick1、onClick2、onClick3等)Flash as3“尝试添加多个”;onClick";事件-我如何做到这一点?,flash,actionscript-3,onclick,flash-cs5,addeventlistener,Flash,Actionscript 3,Onclick,Flash Cs5,Addeventlistener,我正在尝试创建多个addEventListener,但不知道如何创建。正如你在下面的代码中所看到的,我不明白我需要在我写的地方写些什么????????为了产生多个功能(如onClick1、onClick2、onClick3等) for(i=0;i
for(i=0;i
我需要做什么?您不想在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
}
for(i=0;i
您可能对flash上的免费视频教程网站感兴趣:
非常感谢!但我还是不明白如何把这些点联系起来。。假设我单击第N个电影剪辑-我想添加这一行:videoResults[N].isItclicked=true;我需要做什么?我在这里遗漏了什么?这个问题可能需要一个复杂的答案和大量的讨论,这将导致偏离原来的问题主题。我认为最好的办法是提供一个链接,指向如何在flash AS3中创建带有播放列表的视频播放器的教程。任何新问题都可以作为独立问题发布在此处,以保持问题和答案清晰。使用字典而不是数组来存储单击结果。字典可以使用任何对象(例如,MovieClip)作为键,而不仅仅是数字。在这种情况下,我认为您应该解释您的最终目标是什么(即,为什么要创建所有这些侦听器函数),以便我们可以解释实现该目标的更好方法。在循环中创建函数是一个坏主意,因此我们需要更高层次的理解您试图做什么。
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
}