Expression Selectors

Joe Clay | Feb 26, 2018

YouTube user Arthur Hakhverdian asked us a great question about Text Selectors. He wanted to know how to select specific text indexes in an Expression Selector. There's two ways to do it. I would imagine the first would be faster since we don't have to traverse an array. However, to speed it up we put a break in the array traversal method so hopefully it works faster for the first few indices at least.

If you don't have a ton of numbers, this works. just put || between each test.

if(textIndex === 1 || textIndex ===3) {
} else {

Obviously that gets tedious to input a ton of numbers, so you can build an array with a set of numbers to check.

i = [1,3,5,7,10,11];

function inArray(obj) {
    b = 0;
    for(i = 0; i < obj.length; i++) {
        if(obj[i] === textIndex) {
            b = 100;
    return b;

That second one could be tons shorter, but unfortunately AE doesn't have a modern javascript implementation. They seem to still be using 1.2 which is about 20 years old at this point. So I put in a request for them to update it through Adobe's bug/wish form and you should too!

Become a Patron

If you'd like to help support Workbench, check out our Patreon page. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else!

Check out our Patreon Today

Latest tutorials

Workbench tools are used by designers at hundreds of amazing companies