/*
	libPsAnimation
Photoshop フレームアニメーション操作関数

ツールパレットにセットして動作するコードチップ群なので使用時注意
*/

//アクティブフレームに遅延時間を設定 引数は整数でフレーム数
//初期フレームレートは24
if(false){
var myFrames=1;
var myFramerate=24;
var myDesc=new ActionDescriptor();
	myDesc.putReference(
		charIDToTypeID( "null" ),
		new ActionReference().putEnumerated(
			stringIDToTypeID( "animationFrameClass" ),
			charIDToTypeID( "Ordn" ),
			charIDToTypeID( "Trgt" )
		)
	);
	myDesc.putObject(
		charIDToTypeID( "T   " ),
		stringIDToTypeID( "animationFrameDelay" ),
		new ActionReference().putDouble(
			stringIDToTypeID( "animationFrameClass" ),
			new ActionDescriptor().putDouble(
				stringIDToTypeID( "animationFrameDelay" ),myFrames/myFramerate
			)
		)
	);
executeAction(
	charIDToTypeID( "setd" ),
	myDesc,
	DialigModes.NO
);
}
// in 1 line
var myTime=1/24;
var idsetd = charIDToTypeID( "setd" );
    var desc = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref = new ActionReference();
        var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref.putEnumerated( idanimationFrameClass, idOrdn, idTrgt );
    desc.putReference( idnull, ref );
	
    var idT = charIDToTypeID( "T   " );
        var desc2 = new ActionDescriptor();
        var idanimationFrameDelay = stringIDToTypeID( "animationFrameDelay" );
        desc2.putDouble( idanimationFrameDelay, myTime );
    var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
    desc.putObject( idT, idanimationFrameClass, desc2 );
var X=executeAction( idsetd, desc, DialogModes.NO );
//フレームで設定