What application and what version are you using? The script interface differs a bit in latest icon editor. If that is the case, it should look like this:
var image = Document.RasterImage;
var sizeX = image.sizeX;
var sizeY = image.sizeY;
for (x=0; x<sizeX; x )
for (y=0; y<sizeY; y )
if ((x y)&1)
image.SetPixel(x, y, 0, 0, 0);
Here is documentation for scripting in latest version: wiki/Scripting