ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Getting Int instead of string from split();

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Bryan Woods
Getting Int instead of string from split();
on Jan 27, 2017 at 11:19:52 pm

This code works fine in a separate project, but in the current one, it errors with the index number of the layer as the result (which the source text layer doesn't like because its not a string). Whats going on here? It usually outputs a string...

t = thisComp.layer("SourceText").text.sourceText;
word = t.split("\r");
word[index-thisComp.layer("SourceText").effect("Index_Offset")("Slider")]


Return to posts index

Dan Ebberts
Re: Getting Int instead of string from split();
on Jan 28, 2017 at 12:11:40 am

That expression looks like it's loaded with danger. This version should corral things a bit:

t = thisComp.layer("SourceText").text.sourceText;
word = t.split("\r");
idx = clamp(Math.round(index-thisComp.layer("SourceText").effect("Index_Offset")("Slider")),0,word.length-1);
word[idx]


Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]