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>

8 Responses to “Using Spark Containers in MX Navigators”

  1. iiwo says:

    Thx, that’s exactly the tip I was looking for :)

  2. subba says:

    thnks its helpful very much

  3. Mike says:

    Thanks for the tip.
    By the way, are you of African decent. I was wondering because of the black faced fellow you have at the top of your sight.

  4. Brij kishor says:

    Hi
    abobe sample code is not working for flex mobile project. How to create a spark-based ViewStack .

    Thanks
    Brij Kishor

  5. Gagan Deep says:

    Precise answer that i was looking for :)

Leave a Reply