package classes {
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.http.HTTPService;
import mx.controls.Alert;
import mx.charts.series.LineSeries;
public class DrillingLine {
public var brandId:int;
public var domainId:int;
public var overviewEvent:ResultEvent;
public var reportEvents:Object = new Object();
public var lineData:LineSeries;
public var httpService:HTTPService = new HTTPService();
public function DrillingLine(bid:int, did:int):void {
brandId = bid;
domainId = did;
httpServiceInit();
//getOverviewEvent();
}
public function getReport(dateStr:String):ArrayCollection {
if (!(reportEvents[dateStr])) {
_getReport(dateStr); }
return reportEvents[dateStr].result;
}
public function setLineSeries(line:LineSeries):void {
lineData = line;
}
public function getOverview():Object {
return overviewEvent.result;
}
private function _getReport(dateStr:String):void {
reportEvents[dateStr].result = new ArrayCollection();
}
private function httpServiceInit():void {
httpService.requestTimeout=0;
httpService.addEventListener(FaultEvent.FAULT, onFaultHttpService);
}
public function getOverviewEvent():void {
httpService.url = "http://analytics.seomoz.org/analytics/overview/" + brandId.toString() + "/" + domainId.toString();
httpService.addEventListener(ResultEvent.RESULT, setOverviewEvent);
httpService.send();
}
private function setOverviewEvent(re:ResultEvent):void {
overviewEvent = re;
}
private function onFaultHttpService(e:FaultEvent):void
{
Alert.show(e.toString());
}
public function cblabel():String {
Alert.show("in the cblabel function: " + overviewEvent.result.chartdata.title.toString());
return overviewEvent.result.chartdata.title.toString();
}
}
}