Flash CC HTML5应该是简单的gotoAndPlay [英] Flash CC HTML5 ought to be simple gotoAndPlay

查看:286
本文介绍了Flash CC HTML5应该是简单的gotoAndPlay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Flash CC中创建了一个Javascript / HTML5游戏。



我有一个带有按钮的信息屏幕。这个Infoscreen是来自图书馆的一个链接名称为CloseBtn的动画片段。下面的脚本在这个movieclip的第8帧:

 < code> 
this.stop();
var closeBtn = new lib.CloseBtn();
closeBtn.x = 130;
closeBtn.y = 150;
closeBtn.stop();
this.addChild(closeBtn);
closeBtn.addEventListener(click,function(event)
{
this.gotoAndPlay(9);
});
< / code>

当您点击按钮时,您可能已经猜到了InfoScreen中的gotoAndPlay框架9。但它不工作!当我把代码和时间线结合起来的时候,我觉得是错误的吗?

问题解决了!解决方法是在分配eventListener时按钮之前的关键字this。花了我8个小时的代码分析沮丧发现。
$ b $ pre $ this.closeBtn.addEventListener(click,function(event)
{
this.gotoAndPlay (9);
});


I'm creating an Javascript/HTML5-game in Flash CC.

I have an Info-screen with a button. This Infoscreen is a movieclip from the library with a linkname "CloseBtn". The following script is on frame 8 in this movieclip:

<code>
this.stop();
var closeBtn=new lib.CloseBtn();
closeBtn.x=130;
closeBtn.y=150;
closeBtn.stop();
this.addChild(closeBtn);
closeBtn.addEventListener("click", function (event)
{
        this.gotoAndPlay(9);    
});
</code>

As you probably have guessed this should gotoAndPlay frame 9 in the InfoScreen when the button is clicked. But it does not work! Am I thinkg wrong when combining code with timeline?

解决方案

Problem solved!

The solution is the keyword "this" before the button when assigning the eventListener. Took me about 8 hours of frustrated code analysis to find out.

    this.closeBtn.addEventListener("click", function (event)
    {
        this.gotoAndPlay(9);    
    });

这篇关于Flash CC HTML5应该是简单的gotoAndPlay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆