Photoshop's javascript API
I am fairly new to writing javascript code for photoshop. I have read the documentation from adobe about the API and the DOM objects. I have written a number of scripts now and the core of them are built using the output from the script listener tool. My question is, do most people use the code from the script listener or do they try to use the methods in the API? For example if I want to load a saved selection using the API, I can write:
var selRef = app.activeDocument.selection;
selRef.load(app.activeDocument.channels["c1"], SelectionType.REPLACE);or use the 14 lines generated by the script listener.
var idsetd = charIDToTypeID( "setd" );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref1.putProperty( idChnl, idfsel );
desc5.putReference( idnull, ref1 );
var idT = charIDToTypeID( "T " );
var ref2 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
ref2.putName( idChnl, "c1" );
desc5.putReference( idT, ref2 );
executeAction( idsetd, desc5, DialogModes.NO );
