Photoshop not visually updating while script is running?
I wrote a script that SHOULD loop through every frame in my timeline as if it was playing the timeline, however Photoshop doesn't update when I move from frame to frame. I know its going to the frame but almost in the background. I'm wondering why it doesn't just visually show me each frame in my animation. Here is my script now and my play Timeline function is what isn't working. Feel free to try it out to see what I mean.
var doc = app.activeDocument;
var frameCount = getFrameCount();
playTimeline();
function playTimeline() {
frameCount = getFrameCount();
firstFrame();
for(var i = 1; i < frameCount;i++){
goToFrame(i);
$.sleep(getDelay(i) * 1000);
}
}
function getDelay (frame) {
var ref = new ActionReference();
ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('animationFrameDelay'));
ref.putIndex(stringIDToTypeID('animationFrameClass'), frame);
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID('null'), ref);
var T = executeAction(charIDToTypeID('getd'), desc, DialogModes.NO);
return T.getDouble(stringIDToTypeID('animationFrameDelay'));
}
function getFrameCount() {
var count = 1;
while (goToFrame(count) != false) {
count++;
}
return count - 1;
}
function goToFrame(frame) {
try {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putIndex(stringIDToTypeID("animationFrameClass"), frame);
desc.putReference(charIDToTypeID("null"), ref);
executeAction(charIDToTypeID("slct"), desc, DialogModes.NO);
return true;
} catch (e) {}
return false;
}
function firstFrame(){
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(stringIDToTypeID("animationFrameClass"), charIDToTypeID("Ordn"), charIDToTypeID("Frst"));
desc.putReference(charIDToTypeID("null"), ref);
executeAction(stringIDToTypeID("animationFrameActivate"), desc, DialogModes.NO );
}
