Skip to content

Instantly share code, notes, and snippets.

@darscan
Created May 28, 2010 14:14
Show Gist options
  • Save darscan/417190 to your computer and use it in GitHub Desktop.
Save darscan/417190 to your computer and use it in GitHub Desktop.

With automatic mediation waiting for a view component to land on stage is the only way to determine the scope of that view component. When you write “new ViewComp()” there is no way for anyone (other than yourself (a)) to know where that view component is going to end up in the display list hierarchy, and thus no way to determine who should process that view component (which context, and thus, which mediator map).

(a) When manually instantiating the view component you have the opportunity to choose it’s scope sooner:

var vc:ViewComp = new ViewComp();
mediatorMap.createMediator(vc);

As a convenience (and perhaps a hindrance in your case) the mediator waits until the view component is fully initialized before calling onRegister on itself. This “feature” can be found in the mediator’s preRegister hook. If you’d like onRegister to be called sooner (ie immediately), you should override the preRegister hook and call onRegister immediately.

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment