Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Loop through a text array

Participant ,
Feb 24, 2018 Feb 24, 2018

hi!

I want to do a simple loop through a text array and write it out at a given interval.

I thought this would be a simple task but I can't get the actual loop to build on itself – instead I get the end result right away, since how AE interprets code.

Anyone have an easy to use solution for looping through a text array? 

TOPICS
Expressions
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 25, 2018 Feb 25, 2018

Maybe this will give you some ideas:

txt = "this is a line of text";

words = txt.split(" ");

freq = 1; // words per second

n = Math.floor((time - inPoint)/freq);

n = Math.min(n,words.length-1);

str = "";

for (i = 0; i <= n; i++){

  str += (i > 0 ? " " : "") + words;

}

str

Dan

Translate
Community Expert ,
Feb 24, 2018 Feb 24, 2018

An example of what you're trying to do would be helpful.

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 25, 2018 Feb 25, 2018

What I'm trying to do is this:

I've seperated an long text into individual words using .split(). I'm then showing each word for a number of frames running through the whole array.

I also would like to write out the entire sentance word by word in the same tempo. Hence my effort in trying to loop through the entire array – not just the current word but everything from start up to the current word.

I'm not sure how to process this since AE appear to calculate the code to it's end before running it – giving me only the last part of the array not everything from the first TO the last.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2018 Feb 25, 2018
LATEST

Maybe this will give you some ideas:

txt = "this is a line of text";

words = txt.split(" ");

freq = 1; // words per second

n = Math.floor((time - inPoint)/freq);

n = Math.min(n,words.length-1);

str = "";

for (i = 0; i <= n; i++){

  str += (i > 0 ? " " : "") + words;

}

str

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines