Hello Lovely AE Peeps
Slowly, incrementally, I am starting to get a glimmer of how JS works in AE- and then I hit a wall.
I don't understand how time offsetting works, if it can be applied 'deeper' into a script ( at the end of whatever values have been calculated), or if it has to be inserted directly to the source element that is producing the values. But that probably makes no sense, as I don’t know how to even talk about the operations within JS!
What I'm working on is some dynamic text driven animations that can be driven by text numerical values, entered by editors within Adobe Premiere.
For example, here is a simple graph that I have not spiffed up in any way yet:
![Dynamic Text Graph.png]()
The dark red txt in the bottom right are set as guide layers (and will be invisible on renders).They are the Max, and Min Values for the graph, extracted using "parseFloat".
The value I'm representing in a bar graph, I refer to as a "plot". Here is my JS that produced the above image:
All the yellow values on the left are generated on the min/max values entered, and rounded to no decimal places with ".toFixed(0)"
The below script is what drives the white bar graph pictured above:
——————
plotTXT= thisComp.layer("Value input 1").text.sourceText;
plot = parseFloat(plotTXT);
//converts source text into value, for the "plot"
minTXT=thisComp.layer("Min Graph input"). text.sourceText;
min=parseFloat(minTXT);
//converts source text into value, for the "min"
maxTXT=thisComp.layer("Max Graph input"). text.sourceText;
max=parseFloat(maxTXT);
//converts source text into value, for the "max"
net=max-min;
percent=(plot/net);
//does the math to solve what percent the plot is of the net values listed on the graph.
percentANIM=percent*thisComp.layer("Animation").transform.position[0];
//takes an exponential animation from a null object's position (from 0-100), producing a scale up animation, for a transition in.
offset = -.5;
T=time+offset;
offsetAnim=valueAtTime(T);
// this is my scratch pad WIP that is not functioning yet.
[100, percentANIM]
//applies the script to the Y axis of a scale on my bar graph shape layer
(which has an anchor point set at the position of 0 on the graph)
——————
The above script generated this output:
![Dynamic TXT driven Graph_Animated.gif]()
I got as far as I did with time offsetting via this helpful post:
AE Scripting Tutorial: Time Offset Expression
—————
offset = -.5;
//The offset in time, negative half a second.
p = thisComp.layer(“My Animated Layer”);
//The parent layer
t = time + offset;
//The current time minus half a second
p.position.valueAtTime(t);
//Value of the parent’s position property at the current time minus half a second
——————
I’m not having any luck formatting this for my animation type (Position value, from 0-100 on a Null Layer).
Does anyone have any advice on how I could achieve a time offset of the animation from my null layer:
"thisComp.layer("Animation").transform.position[0]”;
so that I could stager the transition in animations of multiple elements, driven by one animation?
I’m hoping to have all the visual elements animate in to their full positions, and to add several more user-enterable bar graphs to the right of the one pictured.
Any help is appreciated
Best,
David