如何在 jsfl 中访问影片剪辑的子级(特别是子级影片剪辑)?
我已经在实例级别从
flash.documents[0].timelines[0].layers[0].frames[0].elements[0].instance
我找到了 this documentation但没有太多其他的。
提前致谢。
最佳答案
在 JSFL 中要记住的是,舞台上的元素也是库中的项目,因此无论您嵌套了多少次,它仍然是库中的剪辑,通常这就是您想要使用的内容.
在您的情况下,它将是:
// break up your previous path to illustrate the "timeline" point
var timeline = flash.documents[0].timelines[0];
// grab the element
var element = timeline.layers[0].frames[0].elements[0];
// get its associated library item (same instance, just a Library Item, not a stage Element)
var item = element.libraryItem;
// then grab the library item's "timeline" property
var childTimeline = item.timeline
// and you can now access any "nested" elements on it
trace(childTimeline.layers[0].frames[0].elements)
乍一看确实有违直觉,但您很快就会习惯。考虑它的最简单方法是,基本上所有元素都是“顶级”的,因为它们都存在于库中。
此外, fl.getDocumentDOM().getTimeline() 是获取当前文档和时间线的常用方法。
关于flash - 使用 JSFL AS3 CS5.5 访问子/嵌套影片剪辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7520652/