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.
Asked
Active
Viewed 6,981 times
1 Answers
15
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.

Dave Stewart
- 2,324
- 2
- 22
- 24
-
1nice technique. Should that be fl.trace on the last line? – josef Apr 02 '14 at 12:23
-
Not if you've aliased it with trace = fl.trace, or you're using xJSFL http://xjsfl.com – davestewart Apr 03 '14 at 12:50
-
THANK YOU. Was absolutely baffled why I couldn't get `selection[i].timeline` when looping through selected items on the stage, but I _could_ get `library.items[i].timeline`. Using `selection[i].libraryItem` is exactly what I needed. – indextwo Apr 28 '19 at 10:59
-
@indextwo - Blimey! This post is 8 years old. Are people still using JSFL? – Dave Stewart Apr 28 '19 at 13:49
-
@DaveStewart If by 'people' you mean me specifically, then: yep! I grew up with Flash, still use it for creating graphics all the time ("stick with a vector editor you know well"), and still code with it. Currently using it to create tile atlases and level editors for my Phaser games! – indextwo Apr 28 '19 at 14:59
-
Ha! Excellent. Did you ever use xJSFL by the way? The site is still up, but I'm considering mothballing the project... – Dave Stewart Apr 28 '19 at 23:01
-
1@DaveStewart Actually, I tried to install it yesterday! I'm much more familiar with jQuery than whatever the hell JSFL actually _is_ (not quite JS, not quite AS, and not really both things either) - but it was throwing an error about some other command modifying something (this was in CS6). I couldn't find the code it highlighted, so I left it. However, as far as I'm aware, JSFL still works in Adobe Animate(!), so it may well be worth keeping it! – indextwo Apr 29 '19 at 12:53
-
110 years later this Answer logic is still a gem. Thank you. – charlesclements Oct 02 '21 at 09:48