访问孩子/嵌套的影片剪辑与JSFL AS3 CS5.5嵌套、影片剪辑、孩子、JSFL

2023-09-09 21:47:56 作者:温瞳

我如何可以访问JSFL影片剪辑的儿童(特别是儿童影片剪辑)? 我已经从实例级别     flash.documents [0] .timelines [0] .layers [0] .frames [0] .elements [0] .instance 我发现本文档,但仅此而已。 提前致谢。

How can I access a movie clip's children (specifically child movie clips) in jsfl? I am already at the instance level from flash.documents[0].timelines[0].layers[0].frames[0].elements[0].instance I've found this documentation but not much else. Thanks in advance.

推荐答案

要记住JSFL的事情是,在舞台上的元素也都在库中的项目,所以它不会不管你有多少次东西嵌套,这是仍在库中的片段,往往这就是你想从工作中的事情。

The thing to remember in JSFL is that elements on stage are also items in the library, so it doesn't matter how many times you have something nested, it's still a clip in the library, and often that's the thing you want to work from.

在你的情况将是:

// 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)

这似乎违反直觉在第一,但你很快就会习惯它。想一想最简单的方法是,基本上所有的元素都是顶级,因为他们都住在库中。

It does seem counter-intuitive at first, but you soon get used to it. The easiest way to think about it is that essentially all elements are "top level" as they all live in the library.

另外之前,fl.getDocumentDOM()getTimeline()是通常的方式来获得当前文档和放大器;时间表。

Also, fl.getDocumentDOM().getTimeline() is the usual way to get the current document & timeline.