Flash CC HTML5 ought to be simple gotoAndPlay

∥☆過路亽.° 提交于 2019-12-11 22:49:19

问题


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?


回答1:


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);    
    });


来源:https://stackoverflow.com/questions/24557262/flash-cc-html5-ought-to-be-simple-gotoandplay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!