Module doesn't get any events, when moved to another container.
Hi.
In my main context view there are several containers (layers). I
load module and add it to context view directly, all works fine, it
initialized and gots events. But when i move module's
convtextView.view to any "layer", my module's convtextView.view's
mediator doesn't gets any events from main app(
Setup layers in main view:
public class InitViewCommand extends Command {
[Inject]
public var view:ContextView;
override public function execute ():void {
view.view.addChild(new FloorLayer());
view.view.addChild(new UILayer());
view.view.addChild(new WindowsLayer());
view.view.addChild(new PreloaderLayer());
}
}
In module:
public class TopBarModule extends Sprite implements IModule {
private var _context:IContext;
private var _view:TopBarView;
public function get view ():DisplayObject {
return _view;
}
// i setup "parent" eventDispatcher to every module
public function setup (dispatcher:IEventDispatcher):void {
_view = new TopBarView;
_context = new Context()
.install(ModuleBundle)
.configure(TopBarConfig)
.configure(new EventDispatcherExtension(dispatcher))
.configure(new ContextView(_view));
}
Load module:
public class LoadModulesCommand extends Command {
...
override public function execute ():void {
context.detain(this);
var loader:BulkLoader = new BulkLoader("modules");
loader.addEventListener(BulkProgressEvent.COMPLETE, loadCompleteHandler);
for each (var link:String in model.modules) {
loader.add(link, {
context: new LoaderContext(false, ApplicationDomain.currentDomain),
maxTries: 5
});
}
loader.start(1);
}
private function loadCompleteHandler (event:BulkProgressEvent):void {
var loader:BulkLoader = BulkLoader.getLoader("modules");
loader.removeEventListener(BulkProgressEvent.COMPLETE, loadCompleteHandler);
for each (var link:String in model.modules) {
var content:IModule = loader.getContent(link) as IModule;
content.setup(dispatcher);
trace(">> init:", content);
contextView.view.addChild(content.view);
}
dispatcher.dispatchEvent(new ModuleEvent(ModuleEvent.INITIALIZE));
context.release(this);
}
}
But if after this i move my "content.view" to any other
container, module's mediator stops to handle any events(
Or this is not valid solution and ScopedEventDispatcherExtension in
any case?
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
1 Posted by ishaban.flash on 28 May, 2013 11:14 AM
Ok, problem is that module's mediator destroys, when i change view's container, and new one doesn't create. Is there any way to avoid it?
2 Posted by matej on 28 May, 2013 11:17 AM
Hey Ivan,
I dont know how to send you PM,
can you contanct me on matej(at)gv3.me
3 Posted by ishaban.flash on 28 May, 2013 01:01 PM
Solution founded, i'm just inject main contentView in modules, and them use it as own. So now, code looks like:
private function loadCompleteHandler (event:BulkProgressEvent):void {
var loader:BulkLoader = BulkLoader.getLoader("modules");
loader.removeEventListener(BulkProgressEvent.COMPLETE, loadCompleteHandler);
for each (var link:String in model.modules) {
var content:IModule = loader.getContent(link) as IModule;
content.setup(dispatcher, contextView);
}
dispatcher.dispatchEvent(new ModuleEvent(ModuleEvent.INITIALIZE));
context.release(this);
}
And in module:
public function setup (dispatcher:IEventDispatcher, contextView:ContextView):void {
_context = new Context()
.install(ModuleBundle)
.configure(BottomBarConfig)
.configure(new EventDispatcherExtension(dispatcher))
.configure(contextView);
}
Support Staff 4 Posted by Shaun Smith on 28 May, 2013 05:41 PM
Do you have logging enabled? Perhaps it can provide some clues as to what is going on under the hood?
Support Staff 5 Posted by Shaun Smith on 28 May, 2013 05:42 PM
Ah, whoops, sorry your replies got marked as spam for some reason. I've restored them.
Ondina D.F. closed this discussion on 04 Jun, 2013 05:02 PM.