I have the following function assigned to a datagrid that contains
checkboxes using click="RegraphTime()"
private function RegraphTime():void
{
//create variable
var monthTotal: Number;
var state:String,prvstate:String,prvstateF:String;
var CurrentState:String;
var Issue:Number;
var Size:Number;
var DSize:Number;
var Adratio:Number;
var mktS:Number;
var mktS2:Number;
var count:Number;
var check:Boolean ;
var statecount:Number;
var current:Number;
monthData = new Array(rawdata.length);
//ini varaible
count=0;
mktS=0;
DSize=0;
Size=0;
Issue=0;
Adratio=0;
mktS2=0;
statecount=1;
//ini array
listdata2 = new Array(rawdata.length);
statelist= new Array(rawdata.length);
//save the first publication name
prvstate=rawdata[0].state;
prvstateF=rawdata[0].stateF;
//statelist[0]={State: state, InGraph: true };
//here we are going to calculate the yearly total for each
publication
//first we need to loop into each row of the raw data
for (var i: Number = 0; i < rawdata.length; i++)
{
Obj= rawdata[i];
current=Obj.date;
state=Obj.state;
//if still the same publication
if(StringUtil.trim(state)==StringUtil.trim(prvstate))
{
//then if withing selected time range 1, add totals
if (from <= current && current <= to )
{
Issue += 1;
}
}
//if different publication
{
if(Issue>0)
{
//add publication total to the arrays
listdata2[count] = {State: prvstate,StateF: prvstateF, Seminar:
Issue, InGraph: true };
count++;
}
state=Obj.state;
prvstate=state;
prvstateF=Obj.stateF;
if (from <= current && current <= to )
{
Issue = 1;
}
else
{
Issue=0;
}
}
}
if(Issue!=0)
{
listdata2[count] = {State: state,StateF: prvstateF, Seminar: Issue,
InGraph: true };
count++;
}
//resize both arrays
listdata2.splice(count);
//copy array
monthData = listdata2.slice(0);
//now that we have a array containing the yearly totals for each
publication
//we have to check which publication to display
statelist = DtgSelection1.selectedItems;
for (i=1;i< statelist.length;i++)
{
var Ro:Object;
Ro = statelist[i];
if(Ro.length!=0)
{
check= Ro[0].selected;
name = Ro[1].text;
for (var y: Number = 0; y < monthData.length; y++)
{
//if the publication is unchecked
if ((monthData[y].stateF ==name) && (check==false))
{
//remove the publication from the array
monthData.splice(y,1);
}
}
}
}
if(count!=0)
populateGrid("ALL");
}
Is there a simplier way?¿?¿ or can you see my error?¿?¿
thanks
JoSh
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/