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

What is Framer? Join the Community
Return to index
John Cross Neumann
Posted Mar 10 - Read on Facebook

what's the best way to reference objects made in the design side with a loop. my head is about to explode. :) thanks in advance.


Peter Ryan Zich

window["Action" + i] in your case

Aalok Trivedi

you can also use the 'select' methods (check out the docs)."Action#{i}").backgroundColor = "red"

Rafael Marin

A couple of other ideas:

1) Store them in a new array:

Actions = [Action0, Action1, Action2, Action3, Action4]

so you'd access them via Actions[1], etc

2) That array already exists, and it's toolbar.children

toolbar.children[1], toolbar.children[2]

3) Access them using their name using
toolbar.childrenWithName("Action0"). Note how this will return an array, because you can have multiple layers with the same name. So to get the only item, it will be stored in the position 0 of that array, or toolbar.childrenWithName("Action0")[0]

Aalok Trivedi

oh duh. Since your Action layers are already in an 'array' (parented), you can also just do:

for Action in toolbar.children
____Action.backgroundColor = "red

Morgan Keys

Another way would be to use the parent layer and .children.

i.e. try:

for layer in toolbar.children
layer.backgroundColor = 'red'

Read the entire post on Facebook