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

What is Framer? Join the Community
Return to index
Essie Zare
Posted Apr 04 - Read on Facebook

Me again with stupid question #2... if you create a bunch of layers in a loop how can you go back and reference them individually? The normal array concept does not seem to work with layers unless I'm completely missing something..


Ben Rodenhäuser

You put them in an array. So you could create an empty array by writing 'layers = []', and then you could continue: 'for i in [0...10] layer = new Layer', and then: `layers.push layer'.

Ben Rodenhäuser

Then layers[0] will be the first layer you created in the for loop, layers[1] the second, and so on.

Vishwas Shetty

parentLyr = new Layer
backgroundColor: "transparent"

for i in [0..6]
lyr = new Layer
name: "Layer" + i
parent: parentLyr
y: i * (100 + 10)

for child in parentLyr.children
print child

Juan J. Ramirez

If you have an array with layers let's say array1 = [layerA, layerB, layerC] you can access them via index: array1[0] ... array1[1] and so on.

Essie Zare

worked like a charm thanks everyone!

Adam Noffsinger

and there's no such thing as a stupid question ;)

Read the entire post on Facebook