That sounds like a crazy amount of work.  Are you manipulating the
ViewStack just to control what is visible on the link bar?

 

Just leave the viewstack alone, use a separate dataProvider for the link
bar, and manipulate that directly to control access the the ViewStack.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of TJ Downes
Sent: Tuesday, September 23, 2008 2:37 PM
To: [email protected]
Subject: [flexcoders] LinkBar + ViewStack + Adding and removing children
= wierdness

 

Here's the simple use case:

I have a viewstack with a few components. Each of these is based on a
panel.

The linkbar controls the viewstack

When the user logs in I remove a child and add two children to the
viewstack

When the user logs out I remove the two children I previously added
and readd the child I removed previously.

On login and logout I set the selectedIndex of the viewstack to 0.

Everything seems to work perfectly fine except when the last child of
the viewstack is selected. The child at index 0 is selected but the
view is not updated to reflect the selection. 

here's some sample code:

private function handleSuccessfulLogin(evt:CustomEvent):void
{
views.removeChildAt(1);

var eventManagerScreen:EventManager = new EventManager();

eventManagerScreen.label = "Event Manager";
eventManagerScreen.title = "Event Manager";
eventManagerScreen.percentHeight = 100;
eventManagerScreen.percentWidth = 100;


var profileScreen:Profile = new Profile();

profileScreen.label = "Profile";
profileScreen.title = "Profile";
profileScreen.percentHeight = 100;
profileScreen.percentWidth = 100;

views.addChildAt(eventManagerScreen, 1);
views.addChildAt(profileScreen, 2);
views.selectedIndex = 0;
}

private function doLogout():void
{
views.removeChildAt(2);
views.removeChildAt(1);

var registrationScreen:RegistrationScreen = new RegistrationScreen();

registrationScreen.label = "Register";
registrationScreen.title = "Register";
registrationScreen.percentHeight = 100;
registrationScreen.percentWidth = 100;

views.addChildAt(registrationScreen,1);
views.selectedIndex = 0;
}


<mx:ViewStack id="views" 
width="100%" height="100%" 
selectedIndex="0">

<ui:EventDisplay id="eventDisplay" 
label="Events"
width="100%" height="100%"/>

<ui:FAQ id="faq" 
label="FAQ" 
title="FAQ" 
width="100%" height="100%"/>

</mx:ViewStack>

 

Reply via email to