这在其他语言中看起来很简单,但我不明白错误。我有7个按钮,当你点击它们时,我希望每个按钮都将我的图库动画片段带到某个框架。将参数传递给mouseEvent函数
Error: 1067: Implicit coercion of a value of type int to an unrelated type flash.events:MouseEvent. Error: 1136: Incorrect number of arguments. Expected 2. Error: 1067: Implicit coercion of a value of type void to an unrelated type Function.
任何帮助?
function gotoImage(event:MouseEvent, frameParam:int):void
{
MovieClip(this.root).gallery.gotoAndStop(frameParam);
}
t1.addEventListener(MouseEvent.CLICK, gotoImage(1));
t2.addEventListener(MouseEvent.CLICK, gotoImage(2));
t3.addEventListener(MouseEvent.CLICK, gotoImage(3));
t4.addEventListener(MouseEvent.CLICK, gotoImage(4));
t5.addEventListener(MouseEvent.CLICK, gotoImage(5));
t6.addEventListener(MouseEvent.CLICK, gotoImage(6));
t7.addEventListener(MouseEvent.CLICK, gotoImage(7));
这确实有用......你能解释一下这里发生了什么吗? – Gisheri
@Gisher MouseEvent处理程序只接受1个参数。你不能用2个参数创建。所以,我写了一个内联函数作为处理函数,并从这个处理函数调用你的函数。 – skabir