Extend Mediators (for Roland)
Because the thread was closed, I am opening a new one.
I've done exactly what you are attempting to do. It's very straightforward.
I have an abstract WindowMediator for my Window class (which extends Sprite) and then I create concrete WindowMediators that extend WindowMediator. The abstract has a protected var window:Window and in the onRegister of the concrete mediator, I set window = the injected concrete view.
public class WindowMediator extends Mediator implements IMediator {
protected var window:Window;
public function WindowMediator()
{
super();
}
override public function onRegister():void
{
eventMap.mapListener(window, Event.CLOSE, onWindowClose, Event);
eventMap.mapListener(window, Event.ACTIVATE, onWindowActivate, Event);
eventMap.mapListener(window, Event.DEACTIVATE, onWindowDeactivate, Event);
eventMap.mapListener(window, Event.ADDED_TO_STAGE, onAddedToStage, Event);
eventMap.mapListener(window, NativeWindowBoundsEvent.RESIZE, onWindowBounds, NativeWindowBoundsEvent);
eventMap.mapListener(window, NativeWindowBoundsEvent.MOVE, onWindowBounds, NativeWindowBoundsEvent);
eventMap.mapListener(window, SystemControlsEvent.CLOSE_WINDOW, onSystemControlClose, SystemControlsEvent);
eventMap.mapListener(window, SystemControlsEvent.MAXIMIZE_WINDOW, onSystemControlMaximize, SystemControlsEvent);
eventMap.mapListener(window, SystemControlsEvent.MINIMIZE_WINDOW, onSystemControlMinimize, SystemControlsEvent);
eventMap.mapListener(window, SystemControlsEvent.RESTORE_WINDOW, onSystemControlRestore, SystemControlsEvent);
super.onRegister();
}
protected function onAddedToStage(event:Event):void
{
// initialization
}
protected function onWindowClose(event:Event):void
{
var owner:Window = (window is ModalWindow) ? ModalWindow(window).owner : null;
dispatch(new WindowLifeEvent(WindowLifeEvent.DESTROY, null, window.uid, owner));
}
protected function onWindowActivate(event:Event):void
{
dispatch(new ApplicationWindowEvent(ApplicationWindowEvent.ACTIVATE, window.uid));
}
protected function onWindowDeactivate(event:Event):void
{
dispatch(new ApplicationWindowEvent(ApplicationWindowEvent.DEACTIVATE, window.uid));
}
protected function onWindowBounds(event:NativeWindowBoundsEvent):void
{
dispatch(new ApplicationWindowEvent(ApplicationWindowEvent.BOUNDS, window.uid, event.afterBounds));
}
protected function onSystemControlClose(event:SystemControlsEvent):void
{
window.nativeWindow.close();
}
protected function onSystemControlMaximize(event:SystemControlsEvent):void
{
window.nativeWindow.maximize();
}
protected function onSystemControlMinimize(event:SystemControlsEvent):void
{
window.nativeWindow.minimize();
}
protected function onSystemControlRestore(event:SystemControlsEvent):void
{
window.nativeWindow.restore();
}
}
public class PanelWindowMediator extends WindowMediator implements IMediator {
[Inject]
public var model:PanelModel;
[Inject]
public var panelWindow:PanelWindow;
public function PanelWindowMediator()
{
super();
}
override public function onRegister():void
{
window = panelWindow;
panelWindow.panel = model.getPanel(window.uid);
super.onRegister();
}
override protected function onWindowClose(event:Event):void
{
model.closeWindow(panelWindow.panel);
super.onWindowClose(event);
}
}
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Shaun Smith on 19 Feb, 2010 09:24 AM
Hi Steven,
Which thread was closed? I thought that even if an issue was "resolved" it could still be re-opened by anyone adding a new comment. Also, as this thread is marked as private (I noticed that on your last thread as well) I think it's only visible to yourself and members of the Robotlegs support team (3 of us at the moment).
2 Posted by stevensacks on 11 Mar, 2010 01:14 AM
I couldn't reopen it. It wouldn't let me. I didn't mean to make this private, either.
Support Staff 3 Posted by Shaun Smith on 11 Mar, 2010 12:04 PM
Oh no! Perhaps closing issues is a bad idea then - I assumed that anyone could re-open any issue by simply continuing the conversation. Will have to look into that. This thread is now public - not sure what's going on there either! Sorry for any hassles.
4 Posted by stevensacks on 12 Mar, 2010 01:15 AM
I made it public. The mystery is solved. ;)
Stray closed this discussion on 10 Feb, 2011 05:03 PM.