这是一个创建于 4479 天前的主题,其中的信息可能已经有所发展或是发生改变。
很多按钮,分别跳到第2帧,3帧,N帧。我这样写的话要写一堆。
怎样只写一个function,然后调用的时候加一个数字就可以跳到相应的帧呢?
function detailshow2(event:MouseEvent) {
gotoAndPlay(2);
}
function detailshow3(event:MouseEvent) {
gotoAndPlay(3);
}
btn1.addEventListener(MouseEvent.MOUSE_UP,detailshow2);
btn2.addEventListener(MouseEvent.MOUSE_UP,detailshow3);
谢谢各位。
2 条回复 • 1970-01-01 08:00:00 +08:00
|
|
1
imcotton 2012-07-03 11:15:46 +08:00 1
var list:Array = [btn1, btn2]; for each (var i:IEventDispatcher in list) i.addEventListener(MouseEvent.CLICK, onClick); function onClick (event:MouseEvent):void { var index:int = list.indexOf(event.target); if (index == -1) return; gotoAndPlay(index + 1); }
|