I wanted to change one value when marker with certain comment starts. I've tried something like this, but it doesn't work.
if (marker.comment("R1 L1").time > time){
value = 40;
}
You need to check how expressions work. An expression sets the value of a property with the first line that returns a value. So for example an expression could just be:
40
since that line returns the value 40. The second line in your expression value = 40
does not return a value, it attempts to set the value
property to 40, which doesn't work, because value
is read-only.
What you need to do is return 40
if the time is after the marker, and if not return the current value
, thus:
if (marker.comment("R1 L1").time > time){
40;
} else {
value;
}
Or more tersely, using ternary notation, which uses the form (condition)? <value if true> : <value if false>
, thus:
(marker.comment("R1 L1").time > time)? 40 : value
I'm not that experienced with expression, so maybe I'm understanding something wrong, but both your code and the code of @stib's answer give me clear error messages. marker.comment
is not a function and above that, the code has several more issues.
Using part of the code from this reference I got the following working:
n = 0;
t = 0;
if (marker.numKeys > 0)
{
n = marker.nearestKey(time).index;
if (marker.key(n).time > time)
n--;
}
if (n > 0 )
t = time - marker.key(n).time;
if(t>0 && marker.key(n).comment=="R1 L1")
40;
else
value;
I've created a simple shape and applied the expression for example to the opacity property (100% at start) and added a marker with the comment "R1 L1" and as soon as the playhead passes this marker the opacity changes to 40%. I think this behaves as intended.