使用JSFL AS3 CS5.5访问子/嵌套影片剪辑

时间:2011-09-22 19:54:26

标签: flash actionscript-3 flash-cs5 jsfl flash-cs5.5

如何在jsfl中访问影片剪辑的子代(特别是子影片剪辑)? 我已经在实例级别了     flash.documents [0] .timelines [0] .layers [0] .frames [0] .elements [0] .instance 我找到了this documentation,但没有其他的。 提前致谢。

1 个答案:

答案 0 :(得分:14)

在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()是获取当前文档的常用方法。时间轴。

相关问题