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

What is Framer? Join the Community
Return to index
Sajid Saiyed
Posted Nov 01 - Read on Facebook

Hi, How do we access variables dynamically from a for loop. For example, I am defining 4 variables and then trying to assign layers to these variables like this but its not working:

B1=""
B2=""
B3 = ""
B4 = ""
for i in [0...4]
B+i = sketch.Buttons.subLayers[i].subLayers[0]

4 Comments

Juan J. Ramirez

You need to store your variables in an array and use the for loop to access them.

Juan J. Ramirez

that gives you this:

Sajid Saiyed

Thanks, I ended up figuring out the same thing :) Managed to get it working. I am building something which I will share soon.

Sajid Saiyed

He is an older version of something that I am refining right now. This works, but I am changing the design and interactions a little bit:

http://share.framerjs.com/7p7ismeyh6ej/

Read the entire post on Facebook