CreateJS : MovieClip.children doesn't update after gotoAndStop()

落花浮王杯 提交于 2019-12-12 02:14:56

问题


CreateJS (2015.11.26) via Animate CC (16.0.0.112)

Structure :

root
 - myContainer
     - frame 0 -> btn_0
     - frame 1 -> btn_1

First frame of root contains following code :

var self = this;
createjs.Ticker.addEventListener("tick", initScreen);

function initScreen() {
    createjs.Ticker.removeEventListener("tick", initScreen);
    self.myContainer.gotoAndStop(1);
}

this.myContainer.addEventListener("click", function(e) {
    console.log("Button 0 : "+self.myContainer.btn_0);
    console.log("Button 1 : "+self.myContainer.btn_1);
});

The result is :

[Log] Button 0 : [MovieClip]
[Log] Button 1 : undefined

And when iterating through self.myContainer.children, only btn_0 exists.

So self.myContainer.children is not being updated when playing through the frames.

Seems like a bug, as I can't find any documentation around this... but I'm surprised that I can't find anyone else who's had this issue.

Any help much appreciated.

(Issue raised here : https://github.com/CreateJS/EaselJS/issues/848)


回答1:


I believe this is because both buttons use the same symbol. In AnimateCC, choose btn_1 and change its "instance of", by swapping-duplicating to a new symbol.

This logged for me:

Button 0 : [MovieClip (name=null)]
Button 1 : [MovieClip (name=null)]


来源:https://stackoverflow.com/questions/42566953/createjs-movieclip-children-doesnt-update-after-gotoandstop

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