简体   繁体   English

Adobe Flash Professional CC gotoAndPlay错误

[英]Adobe flash professional CC gotoAndPlay bug

First of all, hello. 首先,你好。

I have to develop a simple game in flash, usign HTML5 Canvas and JavaScript. 我必须使用Flash,易用的HTML5 Canvas和JavaScript开发一个简单的游戏。 The game, however poor, is pretty much implemented. 该游戏无论多么差劲,都已经实现了。 My problem is, that after you play the game, it shows a try again button, designed to go back to frame 1. When i click the button it goes to frame 1 and returns to frame 25. Any ideas? 我的问题是,玩完游戏后,它会显示一个“重试”按钮,该按钮旨在返回第1帧。当我单击该按钮时,它会转到第1帧并返回第25帧。有什么想法吗?

在此处输入图片说明

The last frame has this code: 最后一帧具有以下代码:

var root = this;
this.stop();
this.tryAgain_btn.addEventListener("click", mouseClickHandler);
function mouseClickHandler(e) {
     root.gotoAndPlay(0);
};

And frame one has this code: 第一帧具有以下代码:

var self = this;
this.stop();    
this.play_btn.addEventListener("click", go);

function go()
{
    self.gotoAndPlay(1);
}

Any ideas on how to solve this? 关于如何解决这个问题的任何想法? Thank you. 谢谢。

Are you developing this in html5 or in actionscript? 您是在html5还是在actionscript中进行开发? Based on your picture of your timeline it looks like you're using actionscript, not a HTML5 Canvas with javascript. 根据您的时间轴图片,看起来您正在使用动作脚本,而不是带有JavaScript的HTML5 Canvas。

Besides that, try using gotoAndStop(1); 除此之外,请尝试使用gotoAndStop(1);。 rather than gotoAndPlay(0) and removing your stop(); 而不是gotoAndPlay(0)并删除stop(); methods. 方法。 Let me know in the comments if it works but since your question is slightly unclear I don't have a grasp on what you're doing. 请在评论中让我知道是否可行,但是由于您的问题尚不清楚,因此我对您的工作一无所知。

EDIT 编辑

Example, in case you don't understand: 例如,如果您不了解:

var root = this;
this.stop();
this.tryAgain_btn.addEventListener("click", mouseClickHandler);

function mouseClickHandler(e) {
    root.gotoAndStop(1);
}

EDIT 2 编辑2

Take a shot at using 尝试使用

this.tryAgain_btn.addEventListener("click", function (event)
{
        this.gotoAndPlay(1);    
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM