Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 904
Brian Wheat Avatar asked Dec 07 '22 19:12

Brian Wheat


1 Answers

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.

like image 167
Dave Stewart Avatar answered Dec 09 '22 13:12

Dave Stewart