ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

problem with an expression (that works in other composition)

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
constanti dinuproblem with an expression (that works in other composition)
by on Sep 24, 2015 at 11:43:51 am

hello guys,
i have a problem applying an expression, that otherwise works in a different situation in a different comp (with some variations).

i have a layer named "Icon options". in this layer there are some sliders named "1", another named "2", "3" and so on
i have another layer named A,and this layer has a slider named "Opacity number".

what i'm trying to achieve is to link the opacity of the layer A to the slider named "1" or "2" or "3" this way:
- in the layer A i want to assign to the slider named Opacity number the number i want, let s say 2
- then i want to use the slider named "2" from "Icon options" to modify the opacity for the layer A

so i've tried

try{
NAME=Math.floor(effect("Opacity number")("Slider"));

thisComp.layer("Icon options").effect(NAME)("Slider");
} catch (err) {
x=[0]
}


in this point, i'm getting the zero value from the fact that it gets an error. if i remove the catch err, i'm getting this error: Class "Effect" has no proprety or method named "Slider"





Any ideas?
Thanks in advance


Return to posts index

Kalle KannistoRe: problem with an expression (that works in other composition)
by on Sep 24, 2015 at 8:20:17 pm

I suspect you are getting Effect("0") due to the floor expression and you have no slider named "0".


Return to posts index

constanti dinuRe: problem with an expression (that works in other composition)
by on Sep 24, 2015 at 8:47:19 pm

the thing is i am using the same expression in other comp, with a little variation, where is linked to a color fill, and it works, like this:

try{
NUME=thisComp.layer(index).name;
x = Math.floor(comp("WORK AREA").layer("COLOR US STATES").effect(NUME)("Slider"));
comp("WORK AREA").layer("COLOR SCHEME").effect(x)("Color");
} catch (err) {
x=[1,1,1,1]
}


Return to posts index


Kalle KannistoRe: problem with an expression (that works in other composition)
by on Sep 25, 2015 at 6:36:29 am

Perhaps because layer numbering starts with 1.

I haven't tried to duplicate your set-up, but try what happens if you change

NAME=Math.floor(effect("Opacity number")("Slider"));

to

NAME=Math.ceil(effect("Opacity number")("Slider"));


Return to posts index

constanti dinuRe: problem with an expression (that works in other composition)
by on Sep 25, 2015 at 6:42:57 am

unfortunately no, the same error


Return to posts index

Kalle KannistoRe: problem with an expression (that works in other composition)
by on Sep 25, 2015 at 8:33:19 am

Looks like the expression is not the problem. I recreated your composition based on your description and I get no error.

9290_iconoptions.aep.zip


Return to posts index


Walter SoykaRe: problem with an expression (that works in other composition)
by on Sep 25, 2015 at 10:31:42 am

[constanti dinu] "in this point, i'm getting the zero value from the fact that it gets an error. if i remove the catch err, i'm getting this error: Class "Effect" has no proprety or method named "Slider""

The error is subtle.

This line:
NAME=Math.floor(effect("Opacity number")("Slider"));
returns an integer. Let's say for the sake of argument, the value is 1.


Now this line:
thisComp.layer("Icon options").effect(NAME)("Slider");

expands to this:
thisComp.layer("Icon options").effect(1)("Slider");


This refers to the first effect on the layer, not to an effect named "1".

A reference to an effect named "1" uses a string, not an integer, like this:
thisComp.layer("Icon options").effect("1")("Slider");

So that first line code needs to store and use the number as a string, not as an integer:
NAME = "" + Math.floor(effect("Opacity number")("Slider"));

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

constanti dinuRe: problem with an expression (that works in other composition)
by on Sep 25, 2015 at 10:44:01 am

YOU SIR, ARE A GENIUS!

i've wrapped my head around this for a week. Your expression line worked like a charmThanks a lot, you actually kind of saved my project.


Also many thanks for everybody else who tried to help me here.

Cheers!


Return to posts index

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