5164 posts
  • Provided great contribution to our forums
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
+12 more
felt_tips Moderator says

So, I’ve got a question then (for Todd, if you’re listening), ‘cos this one may have passed me by too.

Supposing I have used a script to search through a project and find a certain property X on layer Y in comp Z. I’m able to open the comp in a viewer, move focus to the viewer, and I’m able to select the layer and the property inside that comp, but…. am I able to twirl the layer down to reveal the property? The equivalent of hitting “SS” on the keyboard with the layer selected?

I’m fairly sure you can’t, but if it existed, it would be rather useful for scripted search functions.

2353 posts Small, but tough
  • Has referred 500+ members
  • Has sold $125,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 100+ items on Envato Market
+9 more
EFEKT_Studio says

Man, felt_tips is asking questions about scripting and stuff… I must be dreaming :D

5164 posts
  • Provided great contribution to our forums
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
+12 more
felt_tips Moderator says

Man, felt_tips is asking questions about scripting and stuff… I must be dreaming :D

:S:nerdy::D

138 posts After Effects template maniac, freelancer
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Member of the Envato Team
  • Located in United States
+9 more
FluxVFX Envato team says

Hi,
i would like to have an control layer from which you can select one layer from the composition to be activated. Does this work with the layer control expression effect and if yes, how?
Thank’s for your help! :)
By activated do you mean turned on/off?
1556 posts AEdorde.com - After Effects Projects
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has referred 1000+ members
  • Sells items exclusively on Envato Market
+8 more
dorde says
^ Lets suppose that he mean turn on/off. In that case I’m using this expression applied to opacity on layer1:
c =comp("composition_name").layer("layer_with_control").effect("layer1")("Checkbox")
if (c==1){
opacity=100
}else if (c==0){
opacity=0}

I like it and I’m using it, but in that case transparency can be only 0 or 100. That’s not big problem because layer1 can be precomposed and precomposition can contains layer with any opacity value.
346 posts
  • Made it to the Authors' Hall of Fame
  • Has sold $10,000+ on Envato Market
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
+4 more
DOGmotion says
^ the same thing, only a short version without unnecessary details:
c = comp("composition_name").layer("layer_with_control").effect("layer1")("Checkbox");
if (c == 1) opacity = 100
else opacity = 0;
5164 posts
  • Provided great contribution to our forums
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
+12 more
felt_tips Moderator says
^ the same thing, only a short version without unnecessary details:
c = comp("composition_name").layer("layer_with_control").effect("layer1")("Checkbox");
c * 100;
:-)
5164 posts
  • Provided great contribution to our forums
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
+12 more
felt_tips Moderator says

How to use a master Checkbox Control to turn layers on and off (using the value keyword)


I like it and I’m using it, but in that case transparency can be only 0 or 100. That’s not big problem because layer1 can be precomposed and precomposition can contains layer with any opacity value.

That sounds like a lot of extra work. Why not use the value keyword? That gives you the value of the property before the expression.

c =comp("composition_name").layer("layer_with_control").effect("layer1")("Checkbox");
if (c==1){
opacity=value
}else if (c==0){
opacity=0}

...or shorter…
c =comp("composition_name").layer("layer_with_control").effect("layer1")("Checkbox");
c*value;

...or if having the switch on should cause the opacity to be half its original value and having the switch off should cause the opacity to be 15%...

c =comp("composition_name").layer("layer_with_control").effect("layer1")("Checkbox");
c ? value/2 : 15;

Javascript will change the boolean values true and false to 1 or 0, if needs be, depending on what you do with them. Javascript is a loosely typed language and that means it can switch the type of data quite easily from one form to another. See post below for more on Javascript datatypes and the value keyword.

5164 posts
  • Provided great contribution to our forums
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
+12 more
felt_tips Moderator says

Dealing with different data types in expressions.

Javascript (and expressions language) is a loosely typed language and that means it can switch the type of data quite easily from one form to another.

Try this experiment to get a feel for it. Put the following lines of code into the Source Text of a text layer….

note that (5==5) is an expression that evaluates to true and (5==4) is an expression that evaluates to false. The double equals == is used to compare two values, because a single equals = is used to set values. var a = 5 sets the variable a to have a value of 5.

(5==5).toString();
Result: true.
toString() has turned the boolean true value into the word “true”.

(5==4).toString();
Result: false.
The toString() method has turned the boolean false into the word “false”.

(11.3 + (5==5)).toString();
Result: 12.3
Adding 11.3 to true forces the true to be turned into a 1. Then the whole thing is turned into the string “12.3”

"hello there " + (5==5);
Result: hello there true
The boolean true is converted to the string “true” when you try to add it to another string, like “hello there”. In actual fact, the toString() function that I’ve been using on the Source Text property is also superfluous. After Effects will automatically attempt to convert the result to a string, because that’s the type of data that Source Text accepts.

If you want to know what type of value a certain variable holds, you can use typeof... (Note: Anything after // on a line is a comment and does not get evaluated as code.)

typeof "hello"; //Result: "string"
typeof 5; // Result: "number"
typeof true; //Result: "boolean"
typeof effect("Checkbox Control")("Checkbox"); //Result: "object"
typeof effect("Checkbox Control")("Checkbox").value; // Result: number!!! Note: NOT boolean
typeof (typeof 5); //Result: string - typeof returns a string
5164 posts
  • Provided great contribution to our forums
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
+12 more
felt_tips Moderator says

value and valueAtTime()

In expressions, the value keyword can be used to refer to a property’s own value before the expression is applied.

For instance, if you have animated a complicated scaling animation with hundreds of keyframes and you decide you want the animation to be the same, only half as big, you can use the simple expression.
value/2;

This takes whatever the value of scale was and halves it.

If you use value to refer to a property other than the property that the expression is on, you can only retrieve the post-expression value (if it has an expression). As far as I’m aware, there’s no way to retrieve the pre-expression value of a property from outside that property. For instance, this expression on the scale property…

a = thisLayer.effect("Slider Control")("Slider").value;
[a,a];

...will give the post-expression value of Slider Control (if it has an expression).

valueAtTime(t) works similarly, but this method takes an argument… a value inside the brackets that instructs the valueAtTime method which value to return.

thisProperty.valueAtTime(time+1.2);

The expression above will get the property’s pre-expression value 1.2 seconds ahead of the current time. (the keyword time retrieves the current time in seconds) Note: I’ve used the thisProperty keyword to refer to the property itself. I could also have used valueAtTime(time+1.2) on its own.

If I use the valueAtTime(t) method to refer to another property than the property that the expression is on, it works the same, but refers to the post-expression value of that property if there is an expression.

//on the Scale property
a = thisLayer.effect("Slider Control")("Slider").valueAtTime(time+1.2);
[a,a];

Will get the post-expression property (if it has an expression) of Slider Control, 1.2 seconds ahead of the current time.

by
by
by
by
by
by