Flex: view the stack navigator
I have a component mxml file in which I have a view stack, when the button is clicked I go to the first child, now I need to go to the second child at the time of clicking the button present in the second child. All children are compound files that go on the view stack. How it can be done, Sample code is given 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 offer.mxml file, if I try to access the navigationViewStack, I get the error "Accessing properties w90> navigationViewStack.
Help me find out how to access the view stack from my component mxml file.
Thanks!
Cheers, Deena
a source to share
Custom event is the correct and appropriate way; if you need a quick and dirty solution that will eventually become difficult to maintain as your code base grows, you can try this from your button click handler into Offering.mxml
:
ViewStack(this.parent).selectedIndex = 2; //2 for IssueSec
a source to share
Offering.mxml does not have access to navigationViewStack as it is a property inside your Application.mxml file. You will need to dispatch the event from within offer.xml, Application.mxml will listen for this event and handle it by switching to the appropriate view stack element.
If you are unfamiliar with custom events, read the following:
http://livedocs.adobe.com/flex/3/html/help.html?content=createevents_3.html
a source to share
Custom events are the answer to your question. Its a simple look at this example
http://flexblog.faratasystems.com/2007/02/26/event-driven-programming-in-flex-with-custom-events
a source to share