kminev
07-07-2008, 09:44 PM
I had my application working with only hard coded test value into my array collection and now when I switched to from hard coded test data to real data coming from web service something bizarre is happening.
This is the data assignment to my array collection which work:
private function dataResult(event:ResultEvent):void
{
var tmpData:ArrayCollection = event.result.NFS.Trade;
trace('From HTTP to tmpData: ' + event.result.NFS.Trade);
//setting default range values for loading
leftIndicator.x = tmpData.length - 100;
rightIndicator.x = tmpData.length;
rangeData = tmpData;
mainData = new ArrayCollection(rangeData.source);
rangeDataRatio = ((dividedBox.width - 30) / rangeData.length);
trace('Range data ratio from HTTP Service: ' + rangeDataRatio);
}
And this is the new code when I am simply replacing the data source with web service which returns string then I convert it to XML List and from that point I let the array collection take the data from the XML List and this is where something happens and my app doesn't work.
I am assuming it comes from the way I am passing the data to the array collection.
Here is the new function which it doesn't work:
private function tradesByAccIDResult(e:GetDataByAccResultEvent):voi d
{
CursorManager.setBusyCursor();
CursorManager.showCursor();
xmlData = new XMLList(e.result);
var tempData:ArrayCollection = new ArrayCollection();
var trades:Array = [];
for each( var node:XML in xmlData.children() )
{
var trd:TradeModel = new TradeModel(node);
trades.push(trd);
//tempData.addItem({item: new TradeModel(node)});
}
trace('tempData length: ' +tempData.length);
trace('Temp Data Obj: ' + tempData);
trace('Temp Data Source: ' + tempData.source);
loadSeries(xmlData, "W2G");
rangeData = tempData;
leftIndicator.x = rangeData.length - 100;
rightIndicator.x = rangeData.length;
mainData = new ArrayCollection(rangeData.source);
rangeDataRatio = ((dividedBox.width - 30) / rangeData.length);
CursorManager.removeBusyCursor();
}
private function loadSeries(data:XMLList, yAxis:String):void
{
seriesAdd.yField = yAxis;
seriesDelete.yField = yAxis;
seriesChange.yField = yAxis;
seriesAdd.dataProvider = data.Trade.(A == 'Add');
seriesDelete.dataProvider = data.Trade.(A == 'Delete');
seriesChange.dataProvider = data.Trade.(A == 'Change');
}
I am really confused and any help will be greatly appreciated.
This is the data assignment to my array collection which work:
private function dataResult(event:ResultEvent):void
{
var tmpData:ArrayCollection = event.result.NFS.Trade;
trace('From HTTP to tmpData: ' + event.result.NFS.Trade);
//setting default range values for loading
leftIndicator.x = tmpData.length - 100;
rightIndicator.x = tmpData.length;
rangeData = tmpData;
mainData = new ArrayCollection(rangeData.source);
rangeDataRatio = ((dividedBox.width - 30) / rangeData.length);
trace('Range data ratio from HTTP Service: ' + rangeDataRatio);
}
And this is the new code when I am simply replacing the data source with web service which returns string then I convert it to XML List and from that point I let the array collection take the data from the XML List and this is where something happens and my app doesn't work.
I am assuming it comes from the way I am passing the data to the array collection.
Here is the new function which it doesn't work:
private function tradesByAccIDResult(e:GetDataByAccResultEvent):voi d
{
CursorManager.setBusyCursor();
CursorManager.showCursor();
xmlData = new XMLList(e.result);
var tempData:ArrayCollection = new ArrayCollection();
var trades:Array = [];
for each( var node:XML in xmlData.children() )
{
var trd:TradeModel = new TradeModel(node);
trades.push(trd);
//tempData.addItem({item: new TradeModel(node)});
}
trace('tempData length: ' +tempData.length);
trace('Temp Data Obj: ' + tempData);
trace('Temp Data Source: ' + tempData.source);
loadSeries(xmlData, "W2G");
rangeData = tempData;
leftIndicator.x = rangeData.length - 100;
rightIndicator.x = rangeData.length;
mainData = new ArrayCollection(rangeData.source);
rangeDataRatio = ((dividedBox.width - 30) / rangeData.length);
CursorManager.removeBusyCursor();
}
private function loadSeries(data:XMLList, yAxis:String):void
{
seriesAdd.yField = yAxis;
seriesDelete.yField = yAxis;
seriesChange.yField = yAxis;
seriesAdd.dataProvider = data.Trade.(A == 'Add');
seriesDelete.dataProvider = data.Trade.(A == 'Delete');
seriesChange.dataProvider = data.Trade.(A == 'Change');
}
I am really confused and any help will be greatly appreciated.