I recently encounter a problem with Viewstack while switching its
children quickly. the following is part of the codes.
Function "updateState" is used to toggle the viewstack's selected
child according to the boolean parameter "loading". "loadingBar" is a
custom loading component and "viewGrid" is a DataGrid component.
Parameter "true" is passed when a search button is clicked and a
loading bar is presented. Paramenter "false" is passed when remote
data is received and the DataGrid "viewGrid" is presented.
Now the problem is that when I click the search button quickly and
frequently, the alert message could popup occasionally, which could
not happen theoretically.
Anybody can help? Thanks.
private function updateState(loading:Boolean):void
{
if( viewStack == null)
return;
if( loading )
viewStack.selectedChild = loadingBar;
else
viewStack.selectedChild = viewGrid;
if( loading && viewStack.selectedChild == viewGrid
|| !loading && viewStack.selectedChild == loadingBar)
Alert.show(loading.toString() );
}