ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

change color to array desired words

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Peter Zeet
change color to array desired words
on Apr 5, 2017 at 12:08:03 am

Hi!
Is there an easy way to make a text color fill selector work only when certain numbers (or words) within an array are reached?

I have an expression on the source text to add "." on thousands plus the extra + "$", linked to a slider, so I need to have certain values highlighted, like for example

my array=("1.245.345 $", "348.154 $","987.348 $")

thanks!


Return to posts index

Dan Ebberts
Re: change color to array desired words
on Apr 5, 2017 at 3:57:45 am

Something like this for the Amount property of the selector maybe:


myArray=["1.245.345 $", "348.154 $","987.348 $"];
txt = text.sourceText;
gotOne = false;
for (i = 0; i < myArray.length; i++){
if (txt == myArray[i]){
gotOne = true;
break;
}
}
gotOne ? 100 : 0



Dan



Return to posts index

Peter Zeet
Re: change color to array desired words
on Apr 5, 2017 at 6:29:07 pm

works perfect, thank you!!


Return to posts index


Peter Zeet
Re: change color to array desired words
on Apr 6, 2017 at 2:04:52 pm

a quick variation... how it would be adding a fade instead of the 100 value?
I'm doing a linear(time,0,.2,100,0), but it does nothing.
I think I should define time ?


Return to posts index

Dan Ebberts
Re: change color to array desired words
on Apr 6, 2017 at 5:28:35 pm

To make it fade, the expression would need to know how long it has been since the current number changed to its current value. What's driving the changes in the source text?



Return to posts index

Peter Zeet
Re: change color to array desired words
on Apr 6, 2017 at 5:44:43 pm

it's a keyframed slider (with just 2 frames, one with value 0 and other with 100, which drives the final amount, but the place where the last keyframe is may vary)

I have this expression at the text source:



countTotal=3782721;
textBefore = "+";
textAfter = " $";
s=thisComp.layer("control").effect("grow")("Slider");
n="" + Math.round(s*countTotal/100);
s="";
for(i=0, l=n.length; i<l; i++){
if(s && s!="-" && (l-i)%3 ==0)
s+=".";
s += n[i];
}


s+textAfter







Return to posts index


Dan Ebberts
Re: change color to array desired words
on Apr 6, 2017 at 8:07:58 pm

That makes things considerably more complicated. One solution would be to insert another loop, inside the loop that's checking each array element, to go back, frame-by-frame, from the current time to see if that array element shows up within the past .25 seconds (or whatever your ramp time is) and calculate how long ago that was, and use that to drive your linear() or ease() ramp.


Dan



Return to posts index

Peter Zeet
Re: change color to array desired words
on Apr 6, 2017 at 8:42:45 pm

uhm! yes, it gets quite complicated! thanks for the tip!!


Return to posts index

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