RL + Flash CS4
Hi,
I'm trying to figure out and researching but all i find is not something i am looking for (or perhaps i need to look more). My problem is that the component i have in my context view isn't dynamically instantiated but is already there when loaded (view inside the context view), and with the code such as:
// application context script at startup bootstrap
mediatorMap.mapView( myCustomView, myCustomViewMediator );
it seems like myCustomView isn't being mediated because myCustomView loaded already prior to context initialize? In am aware that in flex the context should be instantialize during preinitialize event - but how do i do this in Flash? I am also aware of another way which is:
var cv:myCustomView= new myCustomView();
contextView.addChild(cv);
but then i have to adjust the coordinates of myCustomView programmatically (i.e. cv.x = 100; cv.y = 300) which i am trying to avoid where I can eyeball the layout position during design phase.
I hope my question make sense.
Thanks.
P.S. I'm a seasoned PureMVC user.
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 bitdaemondev on 01 Dec, 2010 10:06 PM
^ bump ...
so how do i mediate an instance in the stage? is that possible?
2 Posted by Stray on 01 Dec, 2010 10:10 PM
if the instance is already on stage, just map the mediator as normal, and then mediate it manually
as in
mediatorMap.createMediator(thingOnStage);
3 Posted by bitdaemondev on 01 Dec, 2010 10:18 PM
didn't work :-s
// context onStartup
Where: view1 is of myCustomView class.
i have a trace inside myCustomViewMediator1 like so: trace('myCustomMediator onRegister'); but is not firing. Is the Context right place to map the instance to it's Mediator?
4 Posted by Abel de Beer on 02 Dec, 2010 12:03 PM
Hmmm that's weird, it works for me! You do override your Context's
startup()
method, right? (because your example says onStartup...)5 Posted by bitdaemondev on 02 Dec, 2010 06:26 PM
yeah ... are you using Flash IDE? I attached the source.
6 Posted by Stray on 02 Dec, 2010 06:37 PM
Any chance that your [Inject] and [PostConstruct] metadata is getting left behind?
That would prevent it from working as it should.
If that's possible, the easiest way to verify that would be to create a dummy command, and map it to ContextEvent.STARTUP_COMPLETE, and inject a constant into it using mapValue, and then test for it on execute and throw an error to tell you whether it has or hasn't been received. Like this:
// in your DummyInjectionTestCommand
[Inject]
public var confirmationOfInjection:String;
... function execute():void
{
if(confirmationOfInjection == null)
{
throw(new Error("The confirmation injection was not fulfilled"));
}
else
{
throw(new Error("Confirmation injection was: " + confirmationOfInjection));
}
}
// in context startup
mapValue(String, " confirming that injection is working just fine");
commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, DummyInjectionTestCommand);
7 Posted by bitdaemondev on 02 Dec, 2010 07:35 PM
yeah, that's my assumption as well but dont know the workaround at the moment ...
8 Posted by Stray on 02 Dec, 2010 07:52 PM
Did you do the test?
If you confirm that the injection isn't working then check out the FAQs for tips on getting injection working in CS4.
https://github.com/robotlegs/robotlegs-framework/wiki/common-problems
9 Posted by bitdaemondev on 02 Dec, 2010 07:54 PM
Trace was:
Error: Confirmation injection was: confirming that injection is working just fine
it's working... so it's odd onRegister is not firing.
10 Posted by bitdaemondev on 03 Dec, 2010 11:10 AM
Ok. found the culprit ... i am suppose to mediate the views inside command controller not in the context ...
and instead of super.startup(); i should issue:
commandMap.mapEvent(ContextEvent.STARTUP, StartupCommand, ContextEvent, true); dispatchEvent(new ContextEvent(ContextEvent.STARTUP));
bitdaemondev closed this discussion on 03 Dec, 2010 05:10 PM.
bitdaemondev re-opened this discussion on 03 Dec, 2010 05:10 PM
bitdaemondev closed this discussion on 06 Dec, 2010 07:34 PM.