I've written a small view-switching component that is based on <mx:Canvas>: <CanvasSwitcher>.
It's set up so that if a child UIComponent is added to it at runtime (eg: via <mx:AddChild> in an <mx:State>), a new <mx:State> is automatically added to the <CanvasSwitcher> instance. The added state is also supplied with an eventListener for the "enterState" event, such that when the <CanvasSwitcher> instance's "currentState" property is set to be equal to the appropriate child UIComponent's "id" property, that UIComponent's "visible" property will be set; all others unset. This works well, looks quite declarative, and has helped to make my current project's interface quite flexible at runtime. The problem is that to be truly useful, I need to be able to add a child, remove it some time later, then re-add it. To do that I need to be able to remove a state from the <CanvasSwitcher> via ActionScript. Can that be done? (I could not see a way in the documentation.) Is this all too crazy? Background: I wanted something quite a bit more flexible than the <mx:ViewStack> component. Particularly, I envisage being able to group UIComponent instances under additional "meta" display states, and to re-group them on the fly. That seems hard/clumsy with <mx:ViewStack>.