【发布时间】:2011-11-23 03:42:13
【问题描述】:
如何在 jsfl 中访问影片剪辑的子项(特别是子影片剪辑)? 我已经处于实例级别 flash.documents[0].timelines[0].layers[0].frames[0].elements[0].instance 我找到了this documentation,但没有别的了。 提前致谢。
【问题讨论】:
标签: flash actionscript-3 flash-cs5 jsfl flash-cs5.5
如何在 jsfl 中访问影片剪辑的子项(特别是子影片剪辑)? 我已经处于实例级别 flash.documents[0].timelines[0].layers[0].frames[0].elements[0].instance 我找到了this documentation,但没有别的了。 提前致谢。
【问题讨论】:
标签: flash actionscript-3 flash-cs5 jsfl flash-cs5.5
在 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() 是获取当前文档和时间线的常用方法。
【讨论】:
selection[i].timeline,但我可以获得library.items[i].timeline。使用selection[i].libraryItem 正是我所需要的。