如何获得父母的孩子(闪光)

时间:2013-03-06 08:36:39

标签: flash actionscript

我正在使用adobe flash cs5,所以

mainTimeline -> {

 child1 movieclip ->{

  //i want from here to get parent.child2, but i get an error that there are no child2

 }

 child2 movieclip ->{

 }

}

我已经为child2 movieclip添加了一个名称并将其导出到actionscript,我也尝试过stage.child2 - 但是他没有看到它,我不知道是什么原因..

1 个答案:

答案 0 :(得分:1)

如果儿童动画片段在时间轴上“彼此相邻”,那么尝试:

child1.parent.child2

或者

(child1.parent).child2

背后的逻辑是child1.parent,应该是对时间轴的引用,然后可以访问child2。

但是,如果你需要做很多事情,那么将child2的引用传递给child1或者重构代码以避免这种情况可能是值得的。通过这种方式可以减少“盲目依赖”或“通过时间线搜索”,并且可能不太容易破损。将来编辑也可能更清晰。