Adobe often has glitches or unfinished features.
The code to load from the act file is like this and it works.
var d = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colorTable"));
d.putReference(stringIDToTypeID("null"), r);
d.putPath(stringIDToTypeID("to"), new File("C:/1/aaa.act"));
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
The code for exporting to the act file should be like this, but it does not work.
var d = new ActionDescriptor();
d.putPath(stringIDToTypeID("null"), new File("C:/1/aaa.act"));
var r = new ActionReference();
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colorTable"));
d.putReference(stringIDToTypeID("to"), r);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
To solve your problem, you can use simplified parsing of the psd file to extract data directly.
try {
var act_file = new File("C:/1/aaa.act"); // your act-file here
var tmp_file = new File(Folder.temp.fsName + "/" + "~tmp.psd");
var d = new ActionDescriptor();
var d1 = new ActionDescriptor();
d1.putBoolean(stringIDToTypeID("maximizeCompatibility"), false);
d.putObject(stringIDToTypeID("as"), stringIDToTypeID("photoshop35Format"), d1);
d.putPath(stringIDToTypeID("in"), tmp_file);
d.putBoolean(stringIDToTypeID("copy"), true);
d.putBoolean(stringIDToTypeID("spot"), false);
d.putBoolean(stringIDToTypeID("alphaChannels"), false);
d.putBoolean(stringIDToTypeID("layers"), false);
d.putBoolean(stringIDToTypeID("embedProfiles"), false);
d.putBoolean(stringIDToTypeID("annotType"), false);
executeAction(stringIDToTypeID("save"), d, DialogModes.NO);
var s = "";
if (!tmp_file.open("r")) { throw("tmp file open error"); }
tmp_file.encoding = "BINARY";
tmp_file.seek(25, 0);
s = tmp_file.read(1);
if (s.charCodeAt(0) != 2) { throw("wrong color mode"); }
s = tmp_file.read(4);
var len = s.charCodeAt(0)<<24 | s.charCodeAt(1)<<16 | s.charCodeAt(2)<<8 | s.charCodeAt(3);
if (len != 0x300) { throw("wrong color len"); }
var table = tmp_file.read(len);
s = tmp_file.read(4);
var len = s.charCodeAt(0)<<24 | s.charCodeAt(1)<<16 | s.charCodeAt(2)<<8 | s.charCodeAt(3);
var data = tmp_file.read(len);
tmp_file.close();
tmp_file.remove();
var color_cnt = 256;
var transp_idx = 0xFFFF;
var n = data.indexOf("8BIM"+ String.fromCharCode(0x04,0x16,0,0,0,0,0,2));
if (n >= 0)
{
color_cnt = data.charCodeAt(n+12)<<8 | data.charCodeAt(n+13);
//alert(color_cnt)
}
var n = data.indexOf("8BIM"+ String.fromCharCode(0x04,0x17,0,0,0,0,0,2));
if (n >= 0)
{
transp_idx = data.charCodeAt(n+12)<<8 | data.charCodeAt(n+13);
//alert(transp_idx)
}
if (!act_file.open("w")) { throw("open error"); }
act_file.encoding = "BINARY";
for (var i = 0; i < 256; i++)
act_file.write(String.fromCharCode(table.charCodeAt(i), table.charCodeAt(256+i), table.charCodeAt(512+i)));
if (color_cnt != 256 || transp_idx != 0xFFFF)
act_file.write(String.fromCharCode(color_cnt>>8, color_cnt&0xFF, transp_idx>>8, transp_idx&0xFF));
if (act_file.error) { throw(act_file.error); }
act_file.close();
alert("done");
}
catch(e) { alert(e); }