AS3 flash为什么提示我的按钮代码函数定义重复
L1——L8是我的按钮,只有一个按钮没报错,我每一个按钮一个图层,求解~~在线等~~我初学AS2,AS3不懂L7.addEventListener(MouseEvent....
L1——L8是我的按钮,只有一个按钮没报错,我每一个按钮一个图层,求解~~在线等~~
我初学AS2,AS3不懂
L7.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 10")
}
L6.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 11")
}
L5.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 15")
}
L4.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 9")
}
L3.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 8")
}
L2.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 4")
}
L1.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 3")
}
还是AS2好使,一段on(press){
gotoAndStop("changjign 2",1)
}
就可以了,但是flash air for android只能用AS3…… 展开
我初学AS2,AS3不懂
L7.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 10")
}
L6.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 11")
}
L5.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 15")
}
L4.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 9")
}
L3.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 8")
}
L2.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 4")
}
L1.addEventListener(MouseEvent.CLICK,hap)
function hap(e){
gotoAndStop(1,"场景 3")
}
还是AS2好使,一段on(press){
gotoAndStop("changjign 2",1)
}
就可以了,但是flash air for android只能用AS3…… 展开
展开全部
你的代码可以这样写:
方法一:
stage.addEventListener(MouseEvent.CLICK,hap);
function hap(e) {
switch (e.target) {
case L7 :
gotoAndStop(1,"场景 10");
break;
case L6 :
gotoAndStop(1,"场景 11");
break;
case L5 :
gotoAndStop(1,"场景 15");
break;
case L4 :
gotoAndStop(1,"场景 9");
break;
case L3 :
gotoAndStop(1,"场景 8");
break;
case L2 :
gotoAndStop(1,"场景 4");
break;
case L1 :
gotoAndStop(1,"场景 3");
break;
}
}
统筹起来,写在一起,在一个函数中,方便管理。张志晨
方法二:
stage.addEventListener(MouseEvent.CLICK,hap);
function hap(e) {
var num:Array=[0,3,4,8,9,15,11,10];
var i:int=Number(e.target.name.substr(1,1));
gotoAndStop(1,"场景 "+num[i]);
}
方法一:
stage.addEventListener(MouseEvent.CLICK,hap);
function hap(e) {
switch (e.target) {
case L7 :
gotoAndStop(1,"场景 10");
break;
case L6 :
gotoAndStop(1,"场景 11");
break;
case L5 :
gotoAndStop(1,"场景 15");
break;
case L4 :
gotoAndStop(1,"场景 9");
break;
case L3 :
gotoAndStop(1,"场景 8");
break;
case L2 :
gotoAndStop(1,"场景 4");
break;
case L1 :
gotoAndStop(1,"场景 3");
break;
}
}
统筹起来,写在一起,在一个函数中,方便管理。张志晨
方法二:
stage.addEventListener(MouseEvent.CLICK,hap);
function hap(e) {
var num:Array=[0,3,4,8,9,15,11,10];
var i:int=Number(e.target.name.substr(1,1));
gotoAndStop(1,"场景 "+num[i]);
}
追问
我的按钮不在一个图层啊
追答
和图层没有关系
方法二:
stage.addEventListener(MouseEvent.CLICK,hap);
function hap(e) {
if(e.target.name.substr(0,1)=="L"){
var num:Array=[0,3,4,8,9,15,11,10];
var i:int=Number(e.target.name.substr(1));
gotoAndStop(1,"场景 "+num[i]);
}
}
更简洁。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询