Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Getting Int instead of string from split();

  • Getting Int instead of string from split();

    Posted by Bryan Woods on January 27, 2017 at 11:19 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")]

    Dan Ebberts replied 9 years, 6 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    January 28, 2017 at 12:11 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

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy