I'm trying to think about the best way to implement nested state transitions in a single stream programming language (Actionscript). Let's say I have a structure like this behavior tree: 
Now imagine that each node sheet is a destination on a website, for example, an image in a gallery, or a comment embedded in a message embedded in a page view ... And the goal is to be able to trigger animated transitions from the node sheet to the node sheet, by animating the previous tree (bottom to top) and animating in the current tree (top to bottom).
So, if we were on the lowest left leaf node, and we wanted to go to the very bottom leaf node, we would have to:
- transition from bottom-left- node
- upon completion (say, after the second animation), move its parent,
- when done go to parent
- on complete, transition to the rightmost parent
- upon completion, the transition in the majority-child
- upon completion, go to sheet
My question is:
If you represent each of these nodes as HTML representations (in which the leaves are "partial", borrowing the term from the rails) or MXML representations where you insert subcomponents and you do not necessarily know the level nest from the application root, what is the best way to animate transition as described above?
One way is to save all possible paths around the world, and then say "Application, transition from this path, transition along this path." This works if the application is very simple. This is how Gaia does it, ActionScript framework. But if you want it to be able to enter / exit arbitrarily nested paths, you cannot store this globally because:
- ActionScript cannot handle all this processing.
- Not like good encapsulation.
So, this question can be reformulated as follows: how do you animate the left leaf of the node, and the parents, starting from the leaf, and liven up in the right leaf of the node, starting from the root? Where is this information stored (what is needed to go inside and out)?
Another possible solution would be to simply say “Application, translate the previous child node, and when it is done, jump to the current child node”, where “child node” is the direct descendant of the application root. Then the left-most root of the application root (which has two child nodes, each of which has two child nodes) will check if it is in the correct state (if its children "crossed"). If not, it will call "transitionOut ()" on them ... Thus, everything will be fully encapsulated. But it looks like this would be a pretty intense processor.
What do you think? Do you have other alternatives? Or you can point me to any useful resources on AI behavior trees or hierarchical state machines that describe how they practically implement asynchronous state transitions:
- Where do they call the "transition" to the object? From a root or a specific child?
- Where is the state stored? Globally, locally? What is the scope that defines what causes "transitionIn ()" and "transitionOut ()"?
I have seen / read many articles / books about AI and state machines, but I still have to find something that describes how they actually implement asynchronous / animated transitions in a complex object-oriented MVC project with 100 views / graphics, involved in a tree of behavior.
Should I call transitions from the parent itself or from the child?
Here are some of the things I learned:
Although this is not necessarily an AI problem, there are no other resources that describe how to apply nested state architectures to websites; these are the closest things.
Another way to formulate the question is: how do you translate state changes into the application? Where do you keep event listeners? How do you find what kind of animation when it is arbitrarily nested?
Note. I'm not trying to create a game, I'm just trying to create animated websites.