我试图在6帧中制作一个块的旋转视图,其中1-4是面向4个边,5-6是顶部和底部。我有4个箭头来旋转"这个观点。 我能够旋转1-6但无法从5& 6回到1-4。 这是我的代码。我对AS不好,所以请回答我的错误......
btn_view_right.addEventListener(MouseEvent.CLICK, viewRight);
function viewRight(event: MouseEvent): void {
if (currentFrame == 1) {
gotoAndStop(2);
} else if (currentFrame == 4) {
gotoAndStop(1);
} else if (currentFrame == 5) {
gotoAndStop(6);
} else if (currentFrame == 6) {
gotoAndStop(5);
} else {
nextFrame();
}
}
btn_view_top.addEventListener(MouseEvent.CLICK, viewTop);
function viewTop(event: MouseEvent): void {
if (currentFrame == 1, 2, 3, 4) {
gotoAndStop(5);
} else if (currentFrame == 5, 6) {
gotoAndStop(1);
}
}
答案 0 :(得分:0)
我认为你在第二个函数中使用的sintax是不正确的,你必须明确地使用or(||)运算符。
试试这段代码:
stop();
btn_view_right.addEventListener(MouseEvent.CLICK, viewRight);
function viewRight(event: MouseEvent): void {
if (currentFrame == 1) {
gotoAndStop(2);
} else if (currentFrame == 4) {
gotoAndStop(1);
} else if (currentFrame == 5) {
gotoAndStop(6);
} else if (currentFrame == 6) {
gotoAndStop(5);
} else {
nextFrame();
}
}
btn_view_top.addEventListener(MouseEvent.CLICK, viewTop);
function viewTop(event: MouseEvent): void {
if (currentFrame == 1 || currentFrame == 2 || currentFrame == 3 || currentFrame == 4) {
gotoAndStop(5);
} else if (currentFrame == 5 || currentFrame == 6) {
gotoAndStop(1);
}
}