PDA

View Full Version : Flex out of sequence processing ?


jaimeker
07-24-2010, 02:51 PM
Hi, I noticed something in my codes that really annoys me.
I have a combo box in my application and assign an arraycollection to the combo box by codes. I need the first element of the arraycollection for other use. However, I constantly notice my program ran into error saying the arraycollection has length 0 and cannot get element from it.
The strange thing is, I am very sure the arraycollection is complete and has about 12 items in it. And the combo box is showing it OK, just while I try to get arraycollection item that it has problem.
It looks like although I ask for item info *AFTER* the arraycollection has been assigned, but the program still reads the line first and get the length of 0 then go into the arraycollection assignation process.
I asked around and some people told me it's because of Flex's timing issue, that it sometimes read line backwards....
Does anyone know how to fix this?

Below are my codes, hope it kind of explains what I said above.


private function cboVisibleMapServices_change():void
{
if (this.blnLayerAssigned == true)
{
var selectedMapService:String = this.cboVisibleMapServices.selectedItem.toString() ;
QBcboLayersArray = mx.core.Application.application.GetLayers(selected MapService); // the array is assigned here and it does get assigned successfully
Alert.show(QBcboLayersArray.length.toString())//this line kept getting 0 while the array length is actually 12

}
}

THANK YOU VERY MUCH IN ADVANCE!!