How to mediate a child clip in a loaded swf

jiri's Avatar


17 Jul, 2010 08:12 AM

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{
    var component:MovieClip;


  1. Support Staff 1 Posted by Shaun Smith on 17 Jul, 2010 10:19 AM

    Shaun Smith's Avatar

    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:

    var clip:MovieClip = swfloaded.getChildByName('myChild');
    mediatorMap.mapView( getQualifiedClassName(clip), ClipMediator, MovieClip );
    mediatorMap.createMediator( clip );

    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. 2 Posted by jiri on 19 Jul, 2010 08:07 AM

    jiri's Avatar


    thanks for your clear answer. Looks like a fine solution.


  3. Stray closed this discussion on 10 Feb, 2011 05:30 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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