send() finish before the result handler has finished?
ravid.paldi Dec 1, 2011 1:28 AMHi,
I'me very new to flash and I have something that I don't understand.
I'm currently using HTTPService to retreive data from my server(Data type A).
My result handler is using a differant HTTPService to retreive data(Data type B) foreach entry of data type A
(The main goal is to create an accordion. each nevigator content is of type A and contains a list of type B)
When I'm using the send() command on the HTTPService type B, its result handler is arranging the data into a new array of VOs.
My problem is that the send() command of type A continues even though its result handler didn't finish its work
( calling send() on type B and arranging the data in VOs) so the data provider for the list in null even though when i'm debuging its not null
I've understand that flash is an event driven language but what is the solution for this kind of situations?
Here is my relevant code:
<fx:Declarations>
<s:HTTPService id="getAllGroups"
url="http://localhost/autoTradePHP/groups/getGroups"
result="getAllGroups_resultHandler(event)"/>
<s:HTTPService id="indicatorsForGroup"
url="http://localhost/autoTradePHP/indicators/indicatorByGroup/{currGroup}"
result="indicatorsForGroup_resultHandler(event)"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
[Bindable]
protected var groupsIDs:ArrayCollection;
[Bindable]
var currGroup:int;
[Bindable]
var currIndicatorList:ArrayCollection;
protected function getAllGroups_resultHandler(eventGroup:ResultEvent):void
{
groupsIDs = eventGroup.result.groups.group;
for (var i:int = 0; i < groupsIDs.length; i++)
{
currGroup = groupsIDs[i].id;
indicatorsForGroup.send();
var nevCon:NavigatorContent = new NavigatorContent;
nevCon.label = groupsIDs[i].name;
var newList:List = new List;
newList.dataProvider = currIndicatorList;
nevCon.addElement(newList);
IndicatorBucket.addChildAt(nevCon,i);
}
}
protected function indicatorsForGroup_resultHandler(eventInd:ResultEvent):void
{
var tmpArr:ArrayCollection;
tmpArr = eventInd.result.indicators.indicator;
// init IndicatorLisr
currIndicatorList = new ArrayCollection;
// go through indicators and add them to array as indicators
for (var i:int = 0; i < tmpArr.length; i++)
{
// create new indicator
var tmpInd:Indicator = new Indicator;
// add its values
tmpInd.group_id = currGroup;
tmpInd.name = tmpArr[i].name;
tmpInd.id = tmpArr[i].id;
// now push it to the indicatorList
currIndicatorList.addItem(tmpInd);
}
}
protected function IndicatorBucket_creationCompleteHandler(event:FlexEvent):void
{
getAllGroups.send();
}
]]>
</fx:Script>
Thanks in advance
Ravid
