Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions toString()? trouble converting interger to string.

  • toString()? trouble converting interger to string.

    Posted by David Jouppi on May 9, 2022 at 4:50 pm

    Hey folks. I feel like this is a pretty basic javascript questions. I’m creating a toolkit and wish to use a dropdown menu to control the selection of a shape layer to use as a matte. However, whenever I try to convert the interger Im getting out of a dropdown menu expression control effect, I’m running into issues. I’m trying to get this expressions to return the string: “Crop_01” but instead, it’s returning “Crop_0[object property]”

    a=thisComp.layer(“BackgroundControls”).effect(“CropSelection”)(“Menu”).toString();
    “Crop_0″+a

    The strange part is that if I remove “toString()” I get “NaN.” Also, if I replace variable a with just the integer “1”, I get it to read properly. Does anyone know what’s going on? Doe dropbown menus return strings? or am I using toString improperly?

    I’m half a mind to use a series of “else if().” to get this working for now, but this problem is bugging me.

    Dan Ebberts
    replied 4 years, 4 months ago
    2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    May 9, 2022 at 5:00 pm

    It works for me without the toString(), but where have you applied this expression?

  • David Jouppi

    May 9, 2022 at 5:09 pm

    Thanks for the quick reply, Dan. I was testing the expression above on the source parameter of a text layer. But I just tried this expression on the path property of a shape layer (where it will end up), and am getting the error below:

    c=thisComp.layer(“BackgroundControls”).effect(“CropSelection”)(“Menu”);
    a=”Crop_0″+c;

    thisComp.layer(a).content(“Group 4”).content(“Path 1”).path

    Error: Bad Method Arguments: incorrect type for argument 1 (expected: ‘int’ provided: ‘NaN’)

  • Dan Ebberts

    May 9, 2022 at 5:38 pm

    Ah. I think you might be using the Legacy ExtendScript expression engine. If you can’t switch to the JavaScript engine for some reason, try changing your fist line to this:

    c = thisComp.layer("BackgroundControls").effect("CropSelection")("Menu").value;

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