ThomasBurleson
8/8/2011 - 5:48 PM

BabelFx with Swiz and Popup Behaviors

BabelFx with Swiz and Popup Behaviors

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:swiz="http://swiz.swizframework.org"
			   minWidth="955" minHeight="600"  >
	<fx:Script>
		<![CDATA[
			import com.codecatalyst.factory.ClassFactory;
			
			import mx.effects.Fade;
			
			import org.swizframework.events.BeanEvent;
			
			import test.swiz.models.Foo;
			import test.swiz.views.PopUpWindow;
			
		]]>
	</fx:Script>

	<fx:Declarations>
		
		<swiz:Swiz id="swiz">
			<swiz:loggingTargets>
				<swiz:SwizTraceTarget/>
			</swiz:loggingTargets>

			<swiz:config>
				<swiz:SwizConfig eventPackages="test.swiz.events.*" 
								 viewPackages="test.swiz.views.*"/>
			</swiz:config>

			<swiz:BeanProvider>
				<fx:Array>
					<swiz:Prototype type="{Foo}"/>
					
					<!-- BabelFx Localization Configuration -->
					<l10n:LocalizationMap   xmlns:l10n="l10n.*"  />
					
				</fx:Array>
			</swiz:BeanProvider>
		</swiz:Swiz>
		
		<!-- Popup Behavior:
		
		     This behavior applies show/hide effects to the popup content [ which is an instance of PopupWindow ], 
		     with autoclose upon mouseDowns outside the popup area, internally caches the content instance for resue, 
		     and registers the content with Swiz so [Inject] works in the PopupWindow. 

		     You can even use anchors/constraints on the popup relative to any parent and offsets relative
		     to some stage point... so positioning of the popup becomes trivial.
		-->

		<ns:Popup id="popup"
			 autoClose="true"
			 showEffect="{ new com.codecatalyst.factory.ClassFactory(Fade,null,{duration:600, alphaFrom:0}) }"
			 hideEffect="{ new com.codecatalyst.factory.ClassFactory(Fade,null,{duration:300, alphaTo:0}) }"
			 contentReady="{ dispatchEvent( new BeanEvent(BeanEvent.SET_UP_BEAN,popup.content ) ) }"
			 xmlns:ns="http://fe.codecatalyst.com/2011/flex-extensions">
			
			<fx:Component>
				<views:PopUpWindow xmlns:views="test.swiz.views.*" />
			</fx:Component>
		</ns:Popup>
		
	</fx:Declarations>

	<s:layout>
		<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
	</s:layout>
	

	<s:Button id="createPopUpButton" label="PopUp" click="popup.show()"/>
</s:Application>