Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Use a dropdown to select an array?

  • Use a dropdown to select an array?

    Posted by Jeff Hinkle on May 14, 2024 at 5:07 pm

    So, I have 40 different shows, each with 4 different layouts and I need to park a day/time box on a specific point on each layout. Sadly, the layouts are slightly different for each show so there’s no “one size fits all” approach.

    So I thought each show has an array of four positions, one for each layout, and select the position via a “Layout” dropdown. Easy enough.

    b=thisComp.layer("controls").effect("layout 2")("Menu"); //value of Layout menu
    show1=[[50,50],[500,50],[50,500],[500,500]]; //array of possible positions show 1
    show2=[[100,100],[500,100],[100,500],[500,100]]; //array of possible positions show 2
    show2[b-1]

    Now the problem I’m hitting is selecting the correct array via a “Show” dropdown. I’ve tried multiple approaches, including an array of names matching the list of array names, selected by the “Show” dropdown. No dice. It seems to return the correct value but AE doesn’t see it as a variable name.

    a=thisComp.layer("controls").effect("show")("Menu"); //value of Show menu
    showList=["show0","show1","show2"];
    showName=showList[a];
    showName[b-1]

    Is there a way to pass a dropdown value to a variable name or is my logic fundamentally faulty?

    Brie Clayton replied 2 years ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    May 14, 2024 at 5:40 pm

    I haven’t tested this, but I would think that you’d want use the actual arrays in your showList, not strings representing their names. So like this:

    showList=[show0,show1,show2];
  • Jeff Hinkle

    May 14, 2024 at 5:51 pm

    Sadly, no. Tried it a few ways and always returns some variation of “Cannot read property of undefined”

    a=thisComp.layer("controls").effect("show")("Menu"); //value of Show menu
    b=thisComp.layer("controls").effect("layout 2")("Menu"); //value of Layout menu
    showList=[show1, show1, show2]; //dummy "show 1" at [0] for safety
    show1=[[50,50],[500,50],[50,500],[500,500]]; //array of possible positions show 1
    show2=[[100,100],[500,100],[100,500],[500,100]]; //array of possible positions show 2
    showName=showList[a]; //showName is [a] value of showList array
    showName[b]
  • Dan Ebberts

    May 14, 2024 at 6:08 pm

    This works for me:

    a=thisComp.layer("controls").effect("show")("Menu"); //value of Show menu
    b=thisComp.layer("controls").effect("layout 2")("Menu"); //value of Layout menu
    show1=[[50,50],[500,50],[50,500],[500,500]]; //array of possible positions show 1
    show2=[[100,100],[500,100],[100,500],[500,100]]; //array of possible positions show 2
    showList=[show1, show1, show2]; //dummy "show 1" at [0] for safety
    showName=showList[a]; //showName is [a] value of showList array
    showName[b-1]
  • Jeff Hinkle

    May 14, 2024 at 6:19 pm

    That DID work! I never knew that the order of variable assignments could be an issue. Thank you as always for the help.

  • Brie Clayton

    May 14, 2024 at 11:32 pm

    Thanks for the solve, Dan!

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