ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Text scroll infinitely via expressions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Stuart Starck
Text scroll infinitely via expressions
on Jul 28, 2017 at 3:02:11 pm

I'm trying desperately to create a horizontal crawl loop for text layers (cnn news crawl like). It sound easy first. Since the text length, comp length and the amount of loop cycles must be variable I dont wanna use any keyframes.

therefore this is a simple solution to scroll infinitely:

x = position[0] + (time-inPoint)*-125;

But there is no option to set an loop point. So I've tried to use:

if(thisComp.layer(index).transform.position[0]>500) x = position[0] + (time)*-25 else 0

and then start all over again. But it obviously cant work!
It seems like there is no option to readout the value while using a function. This drives me crazy. But I can´t figure it out...

any suggestions maybe?


Return to posts index

Dan Ebberts
Re: Text scroll infinitely via expressions
on Jul 28, 2017 at 3:57:06 pm

Hard to say without more specifics, but something like this would probably work:

maxX = 500;
x = position[0] + ((time-inPoint)*-125)%maxX;

Dan



Return to posts index

Stuart Starck
Re: Text scroll infinitely via expressions
on Jul 28, 2017 at 4:33:09 pm

It seems like you've found a good way without more specifics. I'll test it quick and let you know.

Many thx Dan for the fast reply. I'm quite new to this forum, but I've already heard there's nothing you couldn't find a neat solution for. ;-)


Return to posts index


Stuart Starck
Re: Text scroll infinitely via expressions
on Jul 28, 2017 at 6:54:01 pm

Dan, I've changed your script a bit to make it more general, like:

maxX = thisComp.layer(index).sourceRectAtTime(time,false).width + thisComp.width;
x = position[0] + ((time-inPoint)*-125)%maxX;

This works like a charm. But if I take it any further, an interesting thing happens. Here is what this whole thing is all about.

1. I'm reading content from an external txt file, which contains following structure:

sub1 = ["This is a Subline 1"];
sub2 = ["This is a Subline 2"];
sub3 = ["This is a Subline 3"];
etc.

This file may get bigger if the user adds more subs

2. This code allows me to import the content to my textlayer:

var myIndex = thisLayer.name;
$.evalFile("/Users/folder/Desktop/folder/source.txt");
eval(myIndex)[0]

3. according to your idea, this script helps creating an infinite looping horizontal crawl:
(I've changed it a bit due to paragraph settings of the text layer, so it starts out of the visible screen)

maxX = thisComp.width + thisComp.layer(index).sourceRectAtTime(time,false).width
x = position[0] + ((time-inPoint)*-125)%maxX;

4. This happens next. If I add a additional text layer "sub2", "sub3" etc. I have to offset the x position, so they don´t overlay. Otherwise you can´t read it. I've tried the following:

maxX = thisComp.width + thisComp.layer(index).sourceRectAtTime(time,false).width
offset = thisComp.layer(index+1).sourceRectAtTime(time,false).width
x = Math.round((position[0] + ((time-inPoint)*-125)%maxX) + offset);

Now, it seems to work with 2 text layers first, but I'm getting slightly more offset value by increased loop cycles. So after 2 min. it seems to be x times bigger. Imagine what happens if a user uses a comp length of 30 minutes. And I dont think the offset code idea is right, because I'm gonna always miss the text lines before.

Any Idea how to get it done? I would like to use index+1 so you can easly add more text layers without adjusting the code every time.

I've spent almost 2 weeks looking for a solution or ae plugins but there is nothing out there. So I thought doing it by myself with help of the community might be a better way...


Return to posts index

Stuart Starck
Re: Text scroll infinitely via expressions
on Jul 28, 2017 at 7:04:24 pm

I had an another idea of combining all sub layers from a external txt file to one huge line and then do the scrolling thing. I've tried:

$.evalFile("/Users/folder/Desktop/folder/source.txt");
for( i=1 ; i < 12 ; i++ ) {
mysubs += eval("zeile"+i)[0] + " ";
}
mysubs.replace("undefined"," ")

It worked. But I've noticed that AE limits a movement to 30.000 horizontal pixels, which causes the project to crash. Thats why I've decided to split it to single txt layers.


Return to posts index

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