kikito wrote:I didn't get that last part regarding parents and common parents. You mean that when a new state is pushed (for example) the onPause event is fired on all the states of the stack?
Imagine such situation. Let "" be root for whole hierarchy tree, now you have "Menu", "FMV", "Game" under it. "Menu1", "Menu2" under "Menu", "FMV1", "FMV2" under FMV. Now let's have "Game1" and "Game2" under "Game" and "Game1A" and "Game1B" under "Game1". Let's assume that "Game1B" is on top of stack and you are pushing "Menu1".
Normally you would say that you are leaving but will be back to "Game1B" and tell "Menu1" that's it's on now. In that case, you would also tell "Game1" and "Game" that you are leaving and "Menu" that you are entering - even though they are not on stack - but they represent groups of common stuff. But if you change from "Game1B" to "Game1A", you don't do anything - "Game1" is their common parent, so you just tell "Game1B" that you leave it and "Game1A" that it's on now. Notice that "Game1" is first common parent so we don't send anything to it.
That way, you can easily group common initialization and finalizing code, for example responsible for loading common stuff, in groups
You can check transitions I have in other topic I made about it - In my version I use names pushState, popState and changeState (you named it gotoState but it does same thing), and call one transition function that does all the transitions in tree in common way. Events names I use is: "init" for first time visit like pushing state, "enter" for revisit like popping state, "leave" for temporary leave like pushing another state and "exit" for permanent leave, like popping state. I also route standard events to current state
If you use terms like that:
1) inactive state (state not on stack)
2) active state (like on top of stack)
3) frozen state (like on stack but not on top)
this method ensures, that all parents of active states are also active - but don't receive events. And parents of frozen state are active or frozen.
So no, not on all states on the stack - but for all states in hierarchy, that's separate from Stack itself.