brian428 edited this page Sep 14, 2010 · 3 revisions
Clone this wiki locally

Welcome to the swiz-viewmediatorlib wiki!

This custom metadata library is used with the Swiz framework to allow Swiz beans to mediate the creation of view components.


The default metadata argument for MediateView is “view”. You can specify the name of the view class that you are interested in. In this example, when a TestPanel is added to the stage, the setView() method will be invoked, and the view will be passed as a method argument:

[MediateView( "TestPanel" )]
public function setView( panel : TestPanel ) : void
   view = panel;
   view.testLabel.text = "Text set for type TestPanel from controller.";

Another way to use MediateView is to specify a viewId. In this case, when a UIComponent with the ID “testPanel2” is added to the stage, the setView2() method will be invoked, and the view will be passed as a method argument.

[MediateView( viewId="testPanel2" )]
public function setView2( panel : TestPanel ) : void
   view2 = panel;
   view2.testLabel.text = "Text set for id 'testPanel2' from controller.";

When a bean is torn down, references to it are removed from this processor, to allow for proper garbage collection of torn down beans.

To use the library, simply include the MediateViewProcessor in your Swiz tag’s customProcessors:

		<mediateview:MediateViewProcessor id="mediateViewProcessor" />

For an working example, look at my swiz-viewmediatorlib-example repository