-
Highlight text in markers.
Hello again,
Firstly, I’ve been a long time reader of this forum and I’ve only recently posted on here for expression help. The response so far has been awesome, thanks to all who contribute and help others out! I hope to be able to do the same for others soon.
Currently, I have this expression on an expression selector inside a fill color animator.
h = thisComp.layer(“CTRL | Highlights”);
n = 0;
if (h.marker.numKeys > 0){
n = h.marker.nearestKey(time).index;
if (h.marker.key(n).time > time) n–;
if (n > 0) refText = h.marker.key(n).comment;
}
words = refText.replace(/\r?\n|\r/g, ‘ ‘).replace(/\s{2,}/g, ‘ ‘).split(” “);
val = 0;
thisText = text.sourceText.replace(/\r?\n|\r/g, ‘ ‘).replace(/\s{2,}/g, ‘ ‘);
thisWord = thisText.split(” “)[textIndex-1];
for(i = 0; i < words.length; i++){ if (words[i] == thisWord){ val = 100; break; } } val It highlights words that are in the comment of the nearest previous marker. But, when there are no markers on the layer at all, the expression breaks. Is there something I can add which says if there are no markers, just highlight nothing. Matt