Accessing child/nested movie clips with JSFL AS3 CS5.5

元气小坏坏 提交于 2019-12-31 01:02:51

问题


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.


回答1:


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.

In your case it would be:

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

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



来源:https://stackoverflow.com/questions/7520652/accessing-child-nested-movie-clips-with-jsfl-as3-cs5-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!