This content has been marked as final. Show 2 replies
You have two choices. You can pass in the mainViewStack as a property to
your DisplayAllGrid. In your grid class, you'd then save this value and then
modify selectedIndex when you press your link.
The other option is to use parent.parent.selectedIndex (or perhaps further
up the parent chain depending on the scope of the call). Using this is a bit
more hacky and breaks encapsulation. I'd advise using the first technique.
Adobe Flex SDK Developer
"uprise78" <firstname.lastname@example.org> wrote in message
> I cant seem to be able to figure out how to access a viewstack to change
> selected index from within a customer componenet. The structure that I am
> working with is something like this:
> <mx:ViewStack id="mainViewStack" borderStyle="solid">
> <mx:Panel id="displayAll" label="Display All Customers"
> height="100%" headerHeight="6">
> <ns1:DisplayAllGrid verticalCenter="0" horizontalCenter="0"/>
> <mx:Panel id="search" label="Search" width="100%" height="100%">
> <mx:Label text="Search" />
> <mx:Panel id="customerView" label="Customer Information"
> <mx:Label text="Customer View" />
> There is a link in the ":DisplayAllGrid" that I would like to use to
> the mainViewStacks selected panel. Does anyone know how to accomplish
> Thanks in advance,
If the code that you want to set the selectedIndex of the ViewStack is inside the DisplayAllGrid component, you should be able to use parentDocument.mainViewStack.selectedIndex; parentDocument lets you reference things on the document that contains your component. You don't have to -- and shouldn't -- walk parent by parent.
Another approach is to have DisplayAllGrid dispatch some custom event when it want the mainViewStack to change its selectedIndex.Then in mainViewStack's initialize handler, do myDisplayAllGridComponent.addEventListener(...) to register a handler which sets the selected index.