package classes {
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
public class LineCollection extends EventDispatcher {
public static var ACTION:String = "action";
public var lines:Array = new Array();
private var response_count:int = 0;
public function LineCollection(brand_ids:String, domain_ids:String):void {
var brandIds:Array = brand_ids.split("/");
var domainIds:Array = domain_ids.split("/");
for (var i:int = 0; i < maxLength(brandIds, domainIds); i++)
{
var line:DrillingLine = new DrillingLine(brandIds[i], domainIds[i]);
line.httpService.addEventListener(ResultEvent.RESULT, resultAcquired);
line.getOverviewEvent();
Alert.show(i.toString());
lines.push(line);
}
}
public function resultAcquired(re:ResultEvent):void {
response_count = response_count + 1;
if (response_count == lines.length)
{
response_count = 0;
Alert.show("All results have been returned do something");
print_labels();
}
}
public function doAction():void {
dispatchEvent(new Event(LineCollection.ACTION));
}
private function maxLength(brandIds:Array, domainIds:Array):int {
var maxLen:int;
maxLen = brandIds.length;
if (maxLen > domainIds.length) {
maxLen = domainIds.length;
}
return maxLen;
}
public function labels():Array {
var label_array:Array = new Array();
Alert.show("Ok here we are in the labels function...");
for (var i:int = 0; i < lines.length;) {
lines[i].cblabel();
i = i + 1;
}
/*
for each(var line:DrillingLine in lines)
{
Alert.show("Ok here we are in the labels function inside the for loop...");
Alert.show(line.cblabel());
label_array.push(line.cblabel());
}
*/
Alert.show("This is the line we would love to hit");
Alert.show(label_array.length.toString());
return label_array;
}
public function print_labels():void {
//var label_array:Array = labels();
/*
Alert.show(label_array.length.toString());
for each(var label:String in label_array)
{
Alert.show("and the label is... " + label);
}
*/
Alert.show("Ok here we are in print labels...");
labels();
}
}
}