tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/695-mediators-in-flash-cs5Robotlegs: Discussion 2018-10-18T16:35:33Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T18:14:34Z2011-10-13T18:14:34ZMediators in Flash CS5 <div><p>Just use an instance of mediatorMap and use createMediator
method.</p>
<p>Do you have any problems with Flash CS5 as you only mentioned it
in the title?</p></div>Michal Wroblewskitag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T18:22:07Z2011-10-13T18:22:07ZMediators in Flash CS5 <div><p>Hi Nico,</p>
<p>you can manually attach a mediator - just make the mapping as
normal, and then do:</p>
<p>mediatorMap.createMediator(viewOnStage);</p>
<p>This will trigger the mediatorMap to do the same as would happen
if the view had just landed on the stage.</p>
<p>hth,</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T18:28:24Z2011-10-13T18:28:24ZMediators in Flash CS5 <div><p>Ah! Thanks Michal, you beat me to it :)</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T18:35:01Z2011-10-13T18:35:01ZMediators in Flash CS5 <div><p>Thanks so much guys! yeah, I've read it on the docs. One last
question guys, where will i place the createMediator method? From
the looks of it, i think i can only have access to the view inside
the ViewMediator since my view is injected from there. Really sorry
guys for such a noob question >.<</p></div>Nicotag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T18:37:10Z2011-10-13T18:37:11ZMediators in Flash CS5 <div><p>will it also trigger the onRegister event when creating the
mediator manually instead of automatically?</p></div>Nicotag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T18:43:42Z2011-10-13T18:43:42ZMediators in Flash CS5 <div><p>Yes, it will also trigger that.</p>
<p>Where you call it depends entirely on your app - basically you
simply need to make sure you've got access to both the mediatorMap
and the view you want to mediate in the same place.</p>
<p>That could be in the context - as the view is a child of the
contextView, if you can get to it through the contextView (but
you'll obviously need to also keep a strong-typed reference to it
to allow that - at least to it typed as MovieClip so that you can
make use of the dynamic nature of MCs as simply targeting your
nested view on an instance of DisplayObjectContainer should
error).</p>
<p>Let me know if that's not clear,</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T18:54:41Z2011-10-13T18:54:43ZMediators in Flash CS5 <div><p>Thanks so much stray! Ok, so yeah, I think inside the context
would be the best way to go :D but yeah, i just noticed that i dont
have any reference to the view object inside the context. any tips
advice?</p>
<p>I have a reference of the context inside my Document class.</p>
<p>Thank you for your assistance guys :)</p></div>Nicotag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T19:02:10Z2011-10-13T19:02:10ZMediators in Flash CS5 <div><p>You pass your contextView to the context - yes?</p>
<p>So - if that's your root of your FLA, just keep that reference
(typed as a MovieClip).</p>
<p>You should be able to reach the view object through that.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T19:14:47Z2011-10-13T19:14:52ZMediators in Flash CS5 <div><p>Nice! I think i got it now. I manually created the mediator for
my view inside my context. then i created a reference to my view on
the stage by means of contextView.getChildByName("viewObject").</p>
<p>It triggered the onRegister. Question is, is what im doing
correct even if it does work?</p>
<p>ie: Inside my context</p>
<p>var myViewObject:MovieClip =
contextView.getChildByName("viewObject") as MovieClip;</p>
<p>mediatorMap.createMediator(myViewObject);</p></div>Nicotag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T19:23:28Z2011-10-13T19:23:28ZMediators in Flash CS5 <div><p>Hi Nico,</p>
<p>that looks fine to me - but if you're declaring stage instances
automatically (a setting in your swf) then you can just path to it
directly.</p>
<p>What I was thinking was that when you passed in your contextView
you would do:</p>
<p>_flaMovieClip = contextView;</p>
<p>then you can just do</p>
<p>var myViewObject:MovielClip = _flaMovieClip.viewObject;</p>
<p>.... and so on.</p>
<p>But what you're doing looks fine.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/106046272011-10-13T20:41:16Z2011-10-13T20:41:18ZMediators in Flash CS5 <div><p>COOL! Thank you so much guys! you've been a great help!!!</p></div>Nico