Problem with medaitor
I have some problem with views and mediators. I have view named Shop and his mediator.
I mapped it in my context:
mediatorMap.mapView(Shop, ShopMediator);
Then I create object of Shop and add to stage just as user open shop in the game. The problem is that the mediator is not called at all in the application.
Anyone know what is the reason?
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 Ondina D.F. on 24 Oct, 2012 09:00 AM
Hello,
Take a look at this:
https://github.com/robotlegs/robotlegs-framework/wiki/Common-Proble...
Please let us know whether it solved your problem or not.
Ondina
Support Staff 2 Posted by Ondina D.F. on 24 Oct, 2012 09:02 AM
and this:
https://github.com/robotlegs/robotlegs-framework/wiki/Common-Proble...
Support Staff 3 Posted by Ondina D.F. on 24 Oct, 2012 09:46 AM
Is it a Flex or a pure as3 project?
Could you post some code (or attach a simplified example) showing:
-Context initialization in your main display object
-Order of the mappings in your Context
-Where and how you’re adding the view to the display list
-What kind of a component is “Shop”. Is it by any chance a popup container?
I think you’re adding the view to the display list before the mapping was made.
In the case of Mediators the mappings have to occur before their Views hit the stage.
The moment a View is added to the display list the MediatorMap creates a Mediator for that View, but only if they were already mapped.
Exception from the rule: the main application container.
4 Posted by patpas20 on 24 Oct, 2012 08:52 PM
Thanks for replay but any sugestion don't help me. Below pasted a piece of my code.
Context initialization:
Object of shop is create in GameFace:
And was added to scene when player open shop in game:
Of course object of GameFace was added to display list.
Someone know whats wrong is in my code?
Support Staff 5 Posted by Ondina D.F. on 25 Oct, 2012 09:58 AM
Hello,
You didn’t answer my questions, and you didn’t post the code for context initialization in your main class. I can’t see what’s going on from the snippet you posted. I don’t know when is the view added and where. Is GameFace your main class? Also, I don’t know why you’re adding the view twice. [Edit] created the view twice
I guess it’s a pure as3 project. I’ll attach a simple project to show you how you should proceed, and hopefully that will help you :)
Here, just the code for the ContextView.as
1.Bad:
createChildren();
context = new ApplicationContext(this);
Here, SomeView is added to the stage before the mappings in the context occurred, therefore its Mediator (SomeMediator) can’t be created
2.Good:
context = new ApplicationContext(this);//first create the context
createChildren(); //then add the view
Inside the code that I’ve attached to this post there are 4 places where you can add SomeView, and I commented them like this:
[[[option 1]]] ContextView constructor
[[[option 2]]] ContextView on added to stage
[[[option 3]]] ApplicationContext on ContextEvent.STARTUP_COMPLETE
[[[option 4]]] ApplicationMediator onRegister()
I used option 3: ApplicationContext. onStartUpComplete()
It is important that SomeView gets added to the stage after mapping it to its mediator!!
If that doesn’t help you either, you’ll have to attach an example reproducing the issues you’re having, and I’ll take a look at it.
Ondina
Ondina D.F. closed this discussion on 29 Oct, 2012 03:47 PM.