var savefile = new File("~/Desktop/sample.gif");
var gifOpt = new GIFSaveOptions();  // GIF形式オプション
gifOpt.dither=Dither.DIFFUSION; // 誤差拡散
gifOpt.preserveExactColors=true;  // ディザリングしない
activeDocument.saveAs(savefile, gifOpt, true, Extension.LOWERCASE);