Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 555585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:49:47+00:00 2026-05-13T11:49:47+00:00

I am trying to wrap my mind around the best way to implement nested

  • 0

I am trying to wrap my mind around the best way to implement nested state transitions in a single threaded programming language (Actionscript). Say I have a structure like this behavior tree: behavior tree

Now imagine that each leaf node is a destination point on a website, like an image in a gallery, or a comment nested in a post view nested in a page view… And the goal is to be able to run animated transitions from leaf node to leaf node, by animating out the previous tree (from bottom to top), and animating in the current tree (from top to bottom).

So, if we were at the bottom-left-most leaf node, and we wanted to go to the bottom-right-most leaf node, we would have to:

  • transition out bottom-left-node
  • on complete (say after a second of animation), transition out it’s parent,
  • on complete, transition out it’s parent
  • on complete, transition IN the right-most parent
  • on complete, transition in right most-child
  • on complete, transition in leaf

My question is:

If you imagine each of these nodes as HTML views (where the leaves are ‘partials’, borrowing the term from rails), or MXML views, where you’re nesting sub components, and you don’t necessarily know the nest levels from the application root, what is the best way to animate the transition as described above?

One way is to store all possible paths globally, and then to say “Application, transition out this path, transition in this path”. That works if the application is very simple. That’s how Gaia does it, an Actionscript framework. But if you want it to be able to transition in/out arbitrarily nested paths, you can’t store that globally because:

  1. Actionscript couldn’t handle all that processing
  2. Doesn’t seem like good encapsulation

So this question can be reworded as, how do you animate out the left-most-leaf node and it’s parents, starting from the leaf, and animate in the right-most-leaf node, starting with the root? Where is that information stored (what to transition in and out)?

Another possible solution would be to just say “Application, transition out previous child node, and when that’s complete, transition in the current child node”, where the “child node” is the direct child of the application root. Then the left-most child of the application root (which has two child nodes, which each have two child nodes), would check if it’s in the right state (if it’s children are ‘transitioned out’). If not, it would call “transitionOut()” on them… That way everything would be completely encapsulated. But it seems like that’d be pretty processor intensive.

What do you think? Do you have any other alternatives? Or can you point me to any good resources on AI Behavior Trees or Hierarchical State Machines that describe how they practically implement asynchronous state transitions:

  • From where do they call “transitionOut” on an object? From the root or a specific child?
  • Where is the state stored? Globally, locally? What is the scope defining what calls “transitionIn()” and “transitionOut()”?

I have seen/read many articles/books on AI and State Machines, but I have yet to find something describing how they actually implement asychronous/animated transitions in a complex MVC Object Oriented Project with 100s of Views/Graphics participating in the behavior tree.

Should I call the transitions from the parent-most object, or from the child?

Here are some of the things I’ve examined:

  • An Architecture for Game Behavior AI: Behavior Multi-Queues
  • Hierarchical State Machines — a Fundamentally Important Way of Design
  • Programming Game AI by Example
  • Goal-Driven Agent Behavior
  • Advanced State Management by Troy Gardner
  • Troyworks’ AS3 COGS Library
  • Popular Approaches to Behavior-Tree Design
  • Building Event-Driven Conditions for an Asynchronous Sensory System

While this is not necessarily an AI problem, there are no other resources describing how to apply nested state architectures to websites; these are the closest things.

Another way to word the question: How do you broadcast state changes to the application? Where do you keep the event listeners? How do you find what view to animate when it’s arbitrarily nested?

Note: I am not trying to build a game, just trying to build animated websites.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:49:48+00:00Added an answer on May 13, 2026 at 11:49 am

    I’ll try to simplify the problem before suggesting a possible approach. The transitions seem related to the views, and not the model. If I were to skip the transitions and go straight to some other leaf node, the application still works but there is not visual clue for the users. So I’d suggest you use a view-controller specifically to hold the current branch and the transitions of various views.

    It’s probably a better approach to split the two types of transitions into a sort of stack where a pop transition is to go back to a previous node, while a push transition goes forward in the hierarchy. Apple uses a similar technique to manage navigational applications using a navigation view controller. It basically maintains a stack of view controllers that the user followed to get to a particular node. When a user goes back, the top item is popped off the stack, and the user sees the previous item. If the user goes deeper in the hierarchy, a new view controller is pushed onto the stack.

    You would still need a global way to represent the hierarchies in a flyweight manner, while the navigation stack only stores the currently visible branch down to the leaf node.

    If a user went from one leaf node to another, the current stack will be popped out upto the common parent. Then the global tree structure will be asked to get the path from that parent upto the new leaf node. This path of nodes is pushed into the current navigation stack, and as each item is pushed, the transition is shown.

    In a simple algorithm, there’d be these two data structures and a way to get the entire branch that contains leaf node:

    1. a global representation of the tree
    2. a stack of the current branch

    initially:

    stack = []
    tree = create-tree()
    

    algorithm:

    // empty current branch upto the common ancestor, root node if nothing else
    until stack.peek() is in leaf-node.ancestors() {
        stack.pop() // animates the transition-out
    }
    parent = stack.peek();
    // get a path from the parent to leaf-node
    path = tree.get-path(parent, leaf-node)
    for each node in path {
        stack.push(node) // animates the transition-in
    }
    

    Update:

    The entire application could have a single navigation controller, or multiple such controllers. A navigation controller only needs to know that there is a tree which exposes certain operations. So you could create an interface with those operations and let concrete subclasses implement that.

    I can only think of two operations that would need to be exposed (pseudo-Java syntax):

    interface Tree {
        List<Node> getAncestors(node);
        List<Node> findPath(ancestorNode, descendantNode);
    }
    

    That should provide sufficient abstraction to keep the navigation controller poking inside the global tree structure. To take it to the next level, use dependency injection so the tree object is injected into the navigation controller, improving testability and breaking the tree connection completely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 325k
  • Answers 325k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer XslCompiledTransform xslt = new XslCompiledTransform(); String xsltFileName = Server.MapPath("~/page.xsl"); xslt.Load(xsltFileName);… May 14, 2026 at 1:30 am
  • Editorial Team
    Editorial Team added an answer This issue can be resolved by opening the CSProj file… May 14, 2026 at 1:30 am
  • Editorial Team
    Editorial Team added an answer See the example I gave in your other question for… May 14, 2026 at 1:29 am

Related Questions

I am still trying to wrap my mind around the workings of OAuth/OpenID, as
I am trying to wrap my mind around something in java. When I pass
I am currently trying to wrap my mind around Java EE 5. What I'd
I have a project table with projectId as primary key: **projectId**, projectName, dateCreated, etc.
Do you fire ajax requests through the MVC framework of choice, or directly to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.