How to mediate a child clip in a loaded swf
Hello,
Is it somehow possible to have create a mediator at runtime for a
child movieclip in a loaded swf.
I load an swf, add it to the stage and 'know' through some config
that the loaded swf contains a child clip called
myChild
I would then like to create a myChildMediator
that has
myChild
injected in there as the view component.
Because it is already on stage I cannot use automatic mediator
creation, and I also cannot set up the rule, because before the swf
is loaded my main app does not know about myChild
. I
also don't want to mediate the complete loaded swf.
Would named injection be a solution?
So, swf is loaded and added to the stage then:
injector.mapValue(MovieClip , swfloaded.getChildByName('myChild') , 'myChildComponent') injector.instantiate( myChildMediator ); class myChildMediator{ [Inject=(name='myChildComponent')] var component:MovieClip; ... }
Jiri
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 17 Jul, 2010 10:19 AM
It's quite an unusual way to go about things, but yes, that should work. Just be sure to call onRegister() after instantiate(). Also, you will need to clean things up manually if you go this route because the MediatorMap will be unaware of the new mediator instance.
A more standard approach might be to use the MediatorMap:
That way your Mediator will normal (no named injection for view component) and it should be auto-removed when the component leaves the stage (and have a new mediator created if it lands on the stage again later).
2 Posted by jiri on 19 Jul, 2010 08:07 AM
Shaun,
thanks for your clear answer. Looks like a fine solution.
Jiri
Stray closed this discussion on 10 Feb, 2011 05:30 PM.