Search code examples
apache-flexviewstack

Flex: View Stack Navigator


I have a component mxml file in which i have a view stack, on click of a button i navigate to the first child, now i need to navigate to the second child during onclick of a button present in the second child. All the childs are component files included within the view stack. How could this be done, Sample code is present below,

--------------------Application.mxml---------------------

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" >
    <mx:Script>
        <![CDATA[
             private function loadScreen():void
             {
                navigationViewStack.selectedChild=id_offering;  
             }
        ]]>
    </mx:Script>

     <mx:Button label="Save" click="loadScreen();"/>

 </mx:Canvas>

<mx:ViewStack id="navigationViewStack"  width="100%" height="100%">
    <components:dashboard   id="id_dashboard" label="Dashboard" />
    <components:offering   id="id_offering" label="Offering" />
    <components:IssueSec id="id_issueSec" label = "Issues"/>
</mx:ViewStack>

-------------------------Ends--------------------------------------

Now in my offering.mxml file if i try to access navigationViewStack i am getting an error stating 'Access of undefined property navigationViewStack.

Help me on how to access the view stack from my component mxml file.

Thanks!

Cheers, Deena


Solution

  • Custom event is the correct and appropriate way to go; if you want a quick and dirty solution that will eventually become difficult to maintain as your code base grow, you can try this from the button click handler in the Offering.mxml:

    ViewStack(this.parent).selectedIndex = 2; //2 for IssueSec