I mentioned in the post Adding the values of a cfgrid column that if we need to loop over many rows in the cfgrid, we may receive the "A script in this movie is causing Flash Player to run slowly" alert from the Flash Player. In order to avoid that, we'll separate the task in frames:
I mentioned in the post Adding the values of a cfgrid column that if we need to loop over many rows in the cfgrid, we may receive the "A script in this movie is causing Flash Player to run slowly" alert from the Flash Player. In order to avoid that, we’ll separate the task in frames:
var newPrice = Number(amount.text);
var i = 0;
//make the loop with onEnterFrame instead of a "for"
_root.onEnterFrame = function ()
{
if(i < productsGrid.length) {
//do one iteration of the loop
_root.updatePrice(i);
i++;
}
else {
//end the loop
_root.onEnterFrame = undefined;
}
}
//this is the function that does whatever we need in each iteration
_root.updatePrice = function (index){
//edit the row
productsGrid.editField(index, 'price', Number(productsGrid.getItemAt(index)['price']) + newPrice);
//change the color of the edited row
productsGrid.setPropertiesAt(index, {backgroundColor:0xF7FFB7});
}