Kind of dirty, but you can give this a try:
// select frame and set to certain duration;
// 2023, use it at your own risk;
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theCheck = true;
var theFrame = 1;
while (theCheck == true) {
var theCheck = setFrameDuration (theFrame, 0.5);
theFrame++;
var theCheck = setFrameDuration (theFrame, 0.5);
theFrame++;
var theCheck = setFrameDuration (theFrame, 0.05);
theFrame++;
}
};
////// set delay of frame //////
function setFrameDuration (theFrame, theDelay) {
try {
var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
// select frame
var desc2 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putIndex( idanimationFrameClass, theFrame );
desc2.putReference( charIDToTypeID( "null" ), ref1 );
executeAction( charIDToTypeID( "slct" ), desc2, DialogModes.NO );
// set frame’s duration;
var desc3 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated( idanimationFrameClass, charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc3.putReference( charIDToTypeID( "null" ), ref2 );
var desc4 = new ActionDescriptor();
desc4.putDouble( stringIDToTypeID( "animationFrameDelay" ), theDelay );
desc3.putObject( charIDToTypeID( "T " ), idanimationFrameClass, desc4 );
executeAction( charIDToTypeID( "setd" ), desc3, DialogModes.NO );
return true
} catch (e) {return false};
};
////// by michael l hale //////
function GetFrameCount(){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( 'Prpr' ), stringIDToTypeID( "frameCount" ) );
ref.putClass( stringIDToTypeID( "timeline" ) );
var desc = new ActionDescriptor();
desc.putReference( charIDToTypeID( 'null' ), ref );
var resultDesc = executeAction( charIDToTypeID( 'getd' ), desc, DialogModes.NO );
return resultDesc.getInteger( stringIDToTypeID( "frameCount" ) );
};