View Full Version : Text color expression help
Justinger 10-24-2007, 10:45 PM I am rather new to expressions in AE, so I am not quite sure what I am doing wrong.
I am attempting to write an expression that will make certain letters appear as certain colors when typed. For example, if you type "A" it should be red, and whenever you type "B" it should be blue. I have written this, but it seems to assign only my second part, making all text blue. Does anyone have any ideas?
//code to change individual letter colors
//capital A
if (text.animator("Animator 1").property.characterValue = 65)
{
text.animator("Animator 1").property.fillColor = [1,0,0,1];
}
//capital B
if (text.animator("Animator 1").property.characterValue = 66)
{
text.animator("Animator 1").property.fillColor = [0,0,1,1];
}
Thanks,
Justin
|
|
Mylenium
10-25-2007, 05:12 AM
//capital A
if (text.animator("Animator 1").property.characterValue = 65)
{
text.animator("Animator 1").property.fillColor = [1,0,0,1];
}
//capital B
if (text.animator("Animator 1").property.characterValue = 66)
{
text.animator("Animator 1").property.fillColor = [0,0,1,1];
}
You're only defining the testing conditions, not a default case. You're also assigning values (=) rather than comparing them (==) More correctly the expression would look like:
aniColor=text.animator("Animator 1").property.fillColor;
aniChar=text.animator("Animator 1").property.characterValue;
if ( aniChar == 65)
{
aniColor = [1,0,0,1];
}
//capital B
else if (aniChar == 66)
{
aniColor= [0,0,1,1];
}
else{aniColor = value}
As you can see, I also took the liberty of filling in some variables to simplify the code.
Mylenium
Justinger
10-25-2007, 03:07 PM
Thanks for the script corrections. I've learned some helpful fundamentals in your post. Using this script, if I assign the designated number to the character value, the color changes to what we've designated for that number. My ultimate goal is to have this script applied so that when we give it the client, they type out full sentences and every letter is designated different colors on a letter by letter basis. At the moment, it is the entire text block. Any ideas how to accomplish this?
Thanks,
Justin
Justinger
10-25-2007, 05:02 PM
double post, sorry.
Mylenium
10-25-2007, 07:21 PM
Thanks for the script corrections. I've learned some helpful fundamentals in your post. Using this script, if I assign the designated number to the character value, the color changes to what we've designated for that number. My ultimate goal is to have this script applied so that when we give it the client, they type out full sentences and every letter is designated different colors on a letter by letter basis. At the moment, it is the entire text block. Any ideas how to accomplish this?
Thanks,
Justin
That requires a completely different approach and is massively more complex. You use expression selectors for that, not normal range-based ones, split up the string and the run it thru a loop to find all chars for a given color. You possibly need one selector for each color and then still have to add a master controller to define the rules (e.g. make every B blue, but not if it is the neighbor of a red letter or whatever you have in mind). Nothing for the fainthearted and best done by someone offering scripting on a commercial basis.
Mylenium
CGTalk Moderation
10-25-2007, 07:21 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.