It definitely is some sort of race condition but the thing that is
confusing me is the fact that it's reporting that the selected index
and the selected child are those that I'm expecting but the display is
wrong. I've tried adding a validateNow() call before the change but
that hasn't made much difference. 

I'm gonna have to look at my code to figure out a better way for me to
control when this is called, but it really doesn't make much sense to
me why the viewstack is reporting that it's got everything selected as
expected but no matter how much I try to force it to update (by
calling validateNow or invalidateDisplayList etc.) it doesn't seem to
want to show the correct selected index the first time after the
component is loaded.

-D

--- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Sounds like timing.  If you have a button you click to change it, will
> it change the first time?  If so, a validateNow() before you change the
> value might help.
> 
>  
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of dave_defusion
> Sent: Saturday, April 12, 2008 6:21 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] View stack not changing in display even though
> index changes (first time only)
> 
>  
> 
> I have a view stack setup as a custom component, in it there is a
> property call displaySection which is an int that corresponds to the
> index to set the view stack. This is so that I can then use constants
> for each of the sections external to the view and not worry about the
> implementation within the view.
> 
> It is something like follows:
> 
> <mx:Viewstack 
> ...
> selectedIndex="{displaySection}">
> 
> ...
> public static const SECTION_ONE:int = 0;
> (etc.)
> ...
> 
> [Bindable]
> public var displaySection:int = SECTION_ONE;
> ...
> </mx:Viewstack>
> 
> If I then change the displaySection externally and trace out the
> selectedIndex and selectedChild of my component both are as expected,
> however the very first time I do this without fail the display does
> not change and the section displayed is always the default one.
> However if I try and do it again then everything works fine.
> 
> I've tried swapping out the displaySection variable for a setter and
> removed the binding and made the selectedIndex/selectedChild change
> happen within commitProperties() and have traced out the initialized
> property of my view and the length of the children and everything is
> always as I expect it to be. However still no matter what I try
> without fail on the first attempt to change the displaySection it
> never works (always does thereafter --- but with nothing discernibly
> different in the trace).
> 
> I've also tried changing the creationPolicy on the viewstack (and all
> the viewstack children) to all, which didn't make any difference.
> 
> I've run through the debugger also and everything appears to be fine.
> 
> I'm really stuck and I'm ready to throw my computer out of the window.
> 
> Any ideas are greatly appreciated.
>


Reply via email to