Copy link to clipboard
Copied
When i am using expression like the one below, it works well in other enviroments, but in After effects the line highlighted below the whole expression, whenever have spacebar between the "i" and "timeString" values messes up the order of concatenation.
markerTexts = "";
if (thisLayer.marker.numKeys > 0) {
for (i = 1; i <= thisLayer.marker.numKeys; i++) {
markerTime = thisLayer.marker.key(i).time;
markerTime = Math.round(markerTime);
var minutes = Math.floor(markerTime / 60);
var seconds = markerTime - minutes * 60;
var timeString = (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
var markerText = "stuff " + (i < 10 ? "0" : "") + i + ": " + timeString + "\n";
markerTexts += markerText;
}
}
markerTexts;
the line where spacebar messes order of output text that uses this variable (look at the colon between "i" and "timeString"):
var markerText = "stuff " + (i < 10 ? "0" : "") + i + ": " + timeString + "\n";
Here is text with text source generated by expression without spacebar (the numbering of stuff is glued to time codes which is hardly readable):
And here is text after i add spacebar to colon (using code just like the one pasted in this post):
It completely messes up the order - its nothing like in the variable, and it even kind of reverse it (we have colon before the number and even spacebar before the colon, even tho spacebar is after colon in string used in concetanation)
Any idea what is causing it? I have tried multiple ways of concetanation (damn this hard word), and even tried to use different string as separator, and then replacing it outside the loop, but no matter what, whenever the expression gets spacebar there it behaves same way. Whats making AE behave like this?
Question number 2:
Is there a way to make expression force character spacing/tracking to set value only for lets say character that is 5th from the left in each line? I thought about using that insetad of spacebar separator.
Thanks in advance for any help.
Copy link to clipboard
Copied
Add a .toString() to your copunter variable.
Mylenium
Copy link to clipboard
Copied
I'm not seeing that behavior. I'm get results like you would expect with the additional space in there:
stuff 01: 00:01
I'm not sure why it's not working for you.
As for your second question, you could use a source text expression like this to replace a particular character:
txt = value;
n = 5; // replace 5th character
newChar = "*";
txt.substr(0,n-1) + newChar + txt.substr(n)
Copy link to clipboard
Copied
I did a bunch of fiddling with your original expression and even threw in Marker comments, and I can't get it to foul up. Here's the last mod to your code that works just fine for me. The previous version of the expression also counted frames.
markerTexts = "";
if (thisLayer.marker.numKeys > 0) {
for (i = 1; i <= thisLayer.marker.numKeys; i++) {
markerTime = thisLayer.marker.key(i).time;
markerTime = Math.round(markerTime);
var minutes = Math.floor(markerTime / 60);
var seconds = markerTime - minutes * 60;
var timeString = (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
var markerText = thisLayer.marker.key(i).comment + " – " + (i < 10 ? "0" : "") + i + ": " + timeString + "\n";
markerTexts += markerText;
}
}
markerTexts;
I can't make it foul up the list like it did in your screenshots.
Copy link to clipboard
Copied
Yeah its some sort of anomaly. I cant find a reason why it happens aswell. I mean, in other project, where i have used it first time, it worked fine. I was suprised that when used in other project it started malfunctioning, and even when i have created fresh, new project, it was still malfunctioning.
I will play around in spare time with other suggestions, but i have tried some attempts to force treatment as a string and replacement of the placeholder separator with space after the text is generated, and it did not fix the issue.
Will keep trying to find a way or a reason why it happens. For now i have just moved the numbering part in front of the "stuff" as a workaround that works.