-
Function works on dialog but not on a palette
With the help of Andrei I’ve arrived at the code below that works great, but stops working when assigned to a button on a ScriptUi palette. It simply bypasses the ifs in the while loop. I have to change from new Window(“palette”) to new Window(“dialog”) for the function to work.
Since I’m trying to create a dockable script it would be great to have it working on a palette.
Am I missing something?
function Detect(){var comp = app.project.activeItem;
var videoLayer = comp.selectedLayers[0];
var time = comp.time;
var frame = Math.round(time / comp.frameDuration);
var opacityLevel = videoLayer.property("Transform").property("Opacity");
var threshold = 48.0;above = false;
while (frame <= 100) {
t = frame * comp.frameDuration;
if (above) {
if (opacityLevel.valueAtTime(t, true) != threshold) {
frame++;
above = false;
}
} else if (opacityLevel.valueAtTime(t, true) == threshold) {
above = true;
var myMarker = new MarkerValue("Mark");
videoLayer.property("Marker").setValueAtTime(t, myMarker);
}
frame++;
}}