Hello everyone,
I've read some post here regarding mediators and components. However, i want to know more something specific.
Basically, I have a panel view with child views
The panel view is a movieclip which is mediated by "PanelMediator"..
This is in StartupCommand:
// Create and Register the Application and its Mediator.
var app:PanelView= note.getBody() as Shell;
facade.registerMediator(new PanelMediator(app));
Then i had the child views given a mediator, say "SomeChildMediator" passing the component.
This is in PanelMediator:
override public function onRegister():void
{
facade.registerMediator(new SomeChildMediator(panelView.child_mc));
}
private function get panelView():PanelView
{
return viewComponent as PanelView;
}
Now, I add mouse event to the child view component(note the child view also contains related views).
This is in SomeChildMediator:
override public function onRegister():void
{
chilView.btn1.addEventListener(MouseEvent.Click, onBtn1Click);
}
private var onBtn1Click(e:MouseEvent):void
{
//show an btn background, can i do this?
//childView.btn1.background.visible = true;
}
private function get childView():MovieClip
{
return viewComponent as MovieClip;
}
I get that the component or module should encapsulate most of its state and behavior and
exposing only an api, which would look like this(if I'm not mistaken).
PanelView.doSomething();
However, Should "SomeChildMediator" directly change the state? Since it is only mediating the child view of
panelview, which i dont have a class of ChildView.as like PanelView.as. Also i will be dealing with a complex
panel or toolbar soon with lots of buttons(toggle state, some animation).
Thanks in advance........