This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Hamish O'Neill
Posted Jun 05 - Read on Facebook

Hey gang, wondering if it was possible to target layers using variables. I want assign events to a bunch of layers without having to manually code actions for every nav item. Something like the attached. In PHP I used to use eval() to do this. Thanks in advance...


Jonas Treub

If you have targeted the layers in the design tab you can remove the quotes. After putting all targeted layers in an array you can loop over them just like you did. You won't need the brackets inside the loop. Just write:
navItem.onTap => print "yo"

Hamish O'Neill

Ah great, thanks. That works. Now I need to target an artboard within the loop using a variable...

Ramy Majouji

What's "navItem" here? Variable you're using somewhere else?

Read the entire post on Facebook