FORUMS: list search recent posts

Separating expressions using .text.sourceText

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott McGee
Separating expressions using .text.sourceText
on Jul 15, 2016 at 12:58:28 pm

Hey Everyone,

I am new to writing expressions, too which I'm slowly building on.

I've been playing with an expression that allows me to rig the source text so I can use the editable text feature in Premiere from After effects.

input = thisComp.layer("[Colour]").text.sourceText;

if( (input == "red") | (input == "Red") | (input == "RED") == 1 ) value else 0;


I've been finding it quite useful, as I have to normally build 9 different colours that correspond to 5 different stations. When I have to create any network promos, It takes a huge chunk of time to swap, replace, duplicate. I have reduced it to two comps "Station" and "Colour", I type in a the station and colour and wallah.

But I want to reduce it to one comp, because I have to have transparency for a background image, which if I precomped I know would still work. The issue is I have the choice of selecting a colour or selecting what percentage of the transparency I want. I can't mix the two together.

If I put this underneath the above expression.

txt = thisComp.layer("Opacity").text.sourceText.value;
n = parseFloat(txt);
if (isNaN(n)) value else n;


It over rides the above and I can't change the colour, but if I have it above. I can change the colour, but can't alter the opacity.

This is where I'm struggling...How can I use both of these expressions in the Opacity of my layer, and have them assigned to two separate text layers and simultaneously work.

I would ask if there was a way instead of using parseFloat to affect the opacity, but to ask it to change it's blendmode instead would be awesome, but it appears through what I've read...That it can't be done. Instead what I want to do, being able to play with the opacity between 50-75% would be good enough and save me hours when it comes to building 20 promos at a single time.

input = thisComp.layer("[Colour]").text.sourceText;
if( (input == "red") | (input == "Red") | (input == "RED") == 1 ) value else 0;

txt = thisComp.layer("Opacity").text.sourceText.value;
n = parseFloat(txt);
if (isNaN(n)) value else n;


Return to posts index

Kalle Kannisto
Re: Separating expressions using .text.sourceText
on Jul 15, 2016 at 4:54:46 pm

Do these both set the opacity of a given layer based on the two source texts?

If so, perhaps like this?

txt = thisComp.layer("Opacity").text.sourceText.value;
n = parseFloat(txt);
if (isNaN(n)) {op=value} else {op=n}
input = thisComp.layer("[Colour]").text.sourceText;
if((input == "red") | (input == "Red") | (input == "RED")) op else 0


I'm sure this setup can be greatly simplified, too.


Return to posts index

Scott McGee
Re: Separating expressions using .text.sourceText
on Jul 15, 2016 at 7:50:46 pm

If there was a way to simplify it, that would be cool.

But that worked a treat.

Thank you.


Return to posts index


Scott McGee
Re: Separating expressions using .text.sourceText
on Sep 29, 2016 at 9:33:16 am

So i'm now delving into more complex territories and require further assistance from any one who can help.

I am using an Opacity Controller (Keyframing 0 - 100 over a second)

I've then assigned the expression to work with a txt layer to assign an amount for it's delay.

delay = txt = thisComp.layer("Amount").text.sourceText.value;
n = parseFloat(txt);

if (isNaN(n)) value else n;

op = thisComp.layer("OPACITY CONTROLLER").opacity;
d = delay*thisComp.frameDuration*25;
op.valueAtTime(time - (d+1))


Work brilliantly

Then I want to add this expression

input=thisComp.layer("[Station]").text.sourceText;
if ( (input == 'Liverpool Bottom') | (input == 'liverpool bottom') | (input == 'LIVERPOOL BOTTOM') | (input == 'Liverpool bottom') | (input == 'LVB') | (input == 'lvb') == 1 ) value else 0;


These both work separately really well. I've tried mashing them together like the below expression. So that when I pick a station, it will turn that one on or off. Then add an amount for the delay on the opacity controller, to assign the time length.

txt = thisComp.layer("Opacity").text.sourceText.value;
n = parseFloat(txt);
if (isNaN(n)) {op=value} else {op=n}
input = thisComp.layer("[Colour]").text.sourceText;

Any idea's?

With me not being versatile in Java, I don't know whether op is a function that I can change to a randon letter, but there seems to be some conflict somewhere in merging them together.
if((input == "red") | (input == "Red") | (input == "RED")) op else 0


<b>delay = txt = thisComp.layer("Amount").text.sourceText.value;
n = parseFloat(txt);

if (isNaN(n)) value else n;

op = thisComp.layer("OPACITY CONTROLLER").opacity;
d = delay*thisComp.frameDuration*25;
op.valueAtTime(time - (d+1))</b>


Return to posts index

Dan Ebberts
Re: Separating expressions using .text.sourceText
on Sep 29, 2016 at 6:00:58 pm

Ignoring what you've done so far, what is that you're trying to accomplish?

Dan



Return to posts index

Scott McGee
Re: Separating expressions using .text.sourceText
on Sep 29, 2016 at 7:04:07 pm

I have 9 colours, 15 logos and 3 bars and 3 hashtags

What I want to do, when using the editable text in even after effects (For speed), or to be used in.

Type into a text box that affects the following (On and Off)

Which logo is selected
Which Bar is selected
Which hashtag is selected
Which colour is selected

This this expression works fine.

Then the bars need to animate on, this is easy as there is nothing that needs to be affected, other than a delay, which I mention below.

Because the final result can be 3-13 seconds long overall depending on what we want it to be. I want to add a text box too which I can enter a value that will delay the bar and logo before it comes on at a set time.

This expression works fine.

I finally want to assign a ramp up (0-100%) opacity to the logo aswell which is also affected by a delay expression.

This expression works.

So overall. I will select a colour (Pink, red, green etc), the bar will animate on (Left, right or bottom) and the logo (which is one of the 15 selected( 5 for left bar, 5 for right bar and 5 for bottom bar) will fade up for a second after the bar has animated on.

I couldn't combine all three expressions into the opacity to work with my controllers and sourceText boxes. So I figured another way to fix the issue...I've used an expression that hides the logo outside of the comp now assigned to the position. Then merged the parseFloat expression with a delay expression to the sourceText box.

If there is a way to combine the above three expressions that would be cool, as I only have to worry about one whole expression...But I've figured a work around if not.

Sorry for the piss poor explanation and waffling, I'm better at showing than explaining, but I don't have the project in front of me at the moment.


Return to posts index


Dan Ebberts
Re: Separating expressions using .text.sourceText
on Sep 29, 2016 at 7:34:26 pm

I haven't tested this code, but I think it will look something like this:


txt = thisComp.layer("[Colour]").text.sourceText.toLowerCase();
if (text == "red"){
op = thisComp.layer("OPACITY CONTROLLER").opacity;
txt = thisComp.layer("Amount").text.sourceText.value;
delay = parseFloat(txt);
if (isNaN(delay)) delay = 0;
op.valueAtTime(time - delay);
}else
0



Dan



Return to posts index

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