I have read that Views and Controllers should be invisible to each other.
How does the controller then listen for say a button click in the UI view?
Surely the controller needs to know about the view to addEventListeners or the UI view needs to call functions in the controller, or dispatch events to the controller.
My only experience of MVC is with using the robotlegs framework so I’ll try explain my approach when using this framework
My views only use native flash events (MouseEvent.CLICK etc) which are listened for in the mediator for the view. When the mediator receives a native event it will then dispatch an application specific event, LoginEvent.LOGIN for example, which can be mapped to then fire a command using the command map on your context.
Sorry if that doesn’t make much sense, but basically your views fire native events and your mediators will listen for these native events and then fire application specific events which in turn run your commands. You use the mediator as the ‘ears’ for your view and keep any logic out of them. The application context allows you to fire commands whenever certain events occur so your views and commands are seperated.