I'm making an app with flash AS3 and puremvc, the way to correctly handle view mediators is sort of throwing me a little...
OK - I have 3 or 4 distinct views, each governed by it's own mediator. Each view is only displayed on its own - ie. when 1 is visible/on stage - the others are invisible/removed from stage (over simplified, but I guess could be thought of as seperate pages, viewed one at a time, a nav bar allows a user to change views when they like)
At first each view mediator I had creating and added to stage it's own view component, and as such, when it was 'turn' to show or hide that view, it was simple - addChild and removeChild for it's view component.
However, I read over at puremvc.org that it's not good practice to a. pass round the stage (which was the viewComponent for each mediator in my case - where each view was added to - eg. viewComponent.addChild(foo) b. create its own view - which allowed me to add and remove it in the first place.
So I changed to the recommended way - when I create each mediator, what I pass in is the view component it governs (rather than the stage/main doc class)
eg.
var view:MyView = new MyView();
facade.registerMediator( new MyViewMediator( view ) );
viewComponent.addChild(view);
So - with that the case - I have no idea how I would go about removing/adding each view when needed. I could easily enough set the visibility from within each mediator, but I sort of wanted to avoid doing that - prefer removing when not in use for resource management...
Anyone got any good ideas either how I am 'meant' to go about this (as in, when a view is no longer needed on stage, remove it - temporarily, and add it later on when it is needed?) - or am I missing some point (quite likely!) and going about this the wrong way? I'm very new to puremvc so not too confident I am approaching it right. Pointers most welcome!