Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects problem with an expression (that works in other composition)

  • problem with an expression (that works in other composition)

    Posted by Constanti Dinu on September 24, 2015 at 11:43 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

    Constanti Dinu replied 10 years, 7 months ago 3 Members · 7 Replies
  • 7 Replies
  • Kalleheikki Kannisto

    September 24, 2015 at 8:20 pm

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

  • Constanti Dinu

    September 24, 2015 at 8:47 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]
    }

  • Kalleheikki Kannisto

    September 25, 2015 at 6:36 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"));

  • Constanti Dinu

    September 25, 2015 at 6:42 am

    unfortunately no, the same error

  • Kalleheikki Kannisto

    September 25, 2015 at 8:33 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

  • Walter Soyka

    September 25, 2015 at 10:31 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   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Constanti Dinu

    September 25, 2015 at 10:44 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!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy