Using Spark Containers in MX Navigators

I love mx Navigators (ViewStack, TabNavigator etc.) yet when adding spark containers to them you get the error…

The children of Halo navigators must implement INavigatorContent.

If you want to use the new spark containers you need to wrap them in, or just use spark.components.NavigatorContent (not easily found unless your using design view). NavigatorContent itself extends spark.components.SkinnableContainer so you can use it much like a Group and set a custom layout.

<?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:mx="library://ns.adobe.com/flex/mx"
	       minWidth="955" minHeight="600">
 
	<s:layout>
		<s:VerticalLayout/>
	</s:layout>
 
	<mx:ViewStack id="vs" width="400" height="200">
 
		<s:NavigatorContent width="100%" height="100%" backgroundColor="0xFF0000">
			<s:layout>
				<s:VerticalLayout/>
			</s:layout>
			<s:Button label="vertical button 1"/>
			<s:Button label="vertical button 2"/>
			<s:Button label="vertical button 3"/>
		</s:NavigatorContent>
 
		<s:NavigatorContent width="100%" height="100%" backgroundColor="0x0000FF">
			<s:layout>
				<s:HorizontalLayout/>
			</s:layout>
			<s:Button label="horizontal button 1"/>
			<s:Button label="horizontal button 2"/>
			<s:Button label="horizontal button 3"/>
		</s:NavigatorContent>
 
	</mx:ViewStack>
 
	<mx:ToggleButtonBar dataProvider="{vs}"/>
 
</s:Application>

One Response to “Using Spark Containers in MX Navigators”

Leave a Reply