Open davidaurelio opened 12 years ago
These all sound like good changes.
I think optimisation numbers (1) and (2) are absolute necessities since we're ditching registry.movies. (3) sounds good too -- makes things more intuitive.
I guess what'll take the most time is ensuring we have good test coverage for this stuff.
Advance Timeline Tree Depth-First
Current State
stage.loop()
is the central method that “moves the playhead” of all objects having a timeline and currently added to the stage.It loops over all these objects using the movie registry. Objects are added to / removed from it by
addChild()
/removeChild()
.The movie registry contains objects in insertion order. This allows movies inserted during the advancement / looping process to be advanced as well.
Change to Tree Traversal
The request is to change the logic to depth-first hierarchical tree traversal. This makes the actual order easier to predict for developers building things that depend on the tree structure.
Timeline.emitFrame()
method should"tick"
event.currentFrame
and"advance"
events, if playingemitFrame()
method of every child timelineStage.loop()
method shouldemitFrame()
on itself, thus also advancing all submoviesincrementFrame()
method of all timelines. This method could work asemitFrame()
, also invoking the method of child timelines. An optimization idea is described below.Consequences
stage.registry.movies
would go away."tick"
. This most probably isn’t a common usecaseOptimization possibilities
emitFrame()
could take an array parameter which is filled with all timelines encountered. The second iteration (incrementing frame numbers) could be more efficient by simply looping over the filled array.playFrame()
method toTimeline
that simply callsthis.emitFrame()
andthis.incrementFrame()
in order. Would make the whole interface nice and usable without producing unexpected results.