Hi Anthony,
I didn't test your code, but I think the problem lies in your for loops.
When you get such an error it is probably an index out of bounds.
You could try the following, didn't test it by the way.
workData.sortOn("pm");
for(var i:int = 0 ; i < workData.length - 1 ; i++)
{
if(workData[i].pm == workData[i+1].pm)
{
workData.splice(i,1);
i = -1;
}
}
Good luck,
Bernard
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Anthony Cintron
Verzonden: zondag 11 mei 2008 18:55
Aan: [email protected]
Onderwerp: [Flashcoders] merging data problem
Thanks Jason and Juan,
I tested it out and the splicing works really well. One thing I'm noticing
is when I uncomment and add another index, I get a compile error. I messed
with the splice index number, but received unsuccessful results. Any
thoughts on this?
var workData:Array = new Array();
//workData.push({pm:"Bob", resource:"Anthony", client:"Microsoft",
role:"Developer", job:"XXX-XXXX", totalHours:40});
workData.push({pm:"Dan", resource:"Anthony", client:"Microsoft",
role:"Developer", job:"XXX-XXXX", totalHours:50});
workData.push({pm:"Bob", resource:"Anthony", client:"Microsoft",
role:"Developer", job:"XXX-XXXX", totalHours:30});
workData.push({pm:"Dan", resource:"Anthony", client:"Microsoft",
role:"Developer", job:"XXX-XXXX", totalHours:50});
trace(workData);
// for each item in the array
for ( var i = workData.length - 1; i >= 0; i-- ){
// compare to all other array elements
for ( var j = workData.length - 1; j >= 0; j-- )
{
if ( workData[i].pm == workData[j].pm && i != j)
{
for ( var props in workData[i] )
{
workData[i][props] = workData[j][props];
}
trace("index: " + j
);
workData.splice(j, 1);
}
}
}
trace(workData);
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders