简体   繁体   English

Animate CC:单击按钮时如何访问根阶段

[英]Animate CC: How to access root stage when button is clicked

Firstly, I create Canvas Project with Adobe Animate CC. 首先,我使用Adobe Animate CC创建Canvas项目。 But I have a problem with action code. 但是我对操作代码有疑问。

I have 2 symbols on stage. 我在舞台上有2个符号。 How can I get access the symbol on main movie clip? 如何访问主影片剪辑上的符号?

var _this = this;

_this.Text.on('click', function(){

_this.gotoAndPlay('sym2');
});

I need to edit this code to access symbol on main movie clip: 我需要编辑以下代码以访问主影片剪辑上的符号:

https://www.dropbox.com/s/9em62bbifwaxqv4/test2.fla?dl=0 https://www.dropbox.com/s/9em62bbifwaxqv4/test2.fla?dl=0

This seems to be a scoping issue. 这似乎是一个范围界定的问题。 In test2.fla, your object named Text is contained with an object named TradeMarks. 在test2.fla中,名为Text的对象与名为TradeMarks的对象一起包含。

The code in your clip read: 片段中的代码为:

_this.Text.on('click', function(){
    _this.parent.sym2.gotoAndPlay(3);
});

Whereas that would look for an object named "sym2" on TradeMarks, not at the root timeline. 而这将在商标上而不是根时间轴上查找名为“ sym2”的对象。

I think you will get what you want by changing it to read: 我认为将其更改为以下内容即可获得所需的内容:

_this.Text.on('click', function(){
    _this.parent.parent.sym2.gotoAndPlay(3);
});

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

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