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

What is Framer? Join the Community
Return to index
Gavin McFarland
Posted Jul 01 - Read on Facebook

Can anyone show me how you create an array of layers?

I'd like to create 9 layers with the same dimensions but 1) all be unique 2) and are different colours.

For example I'd like to do something like...

for i in [1..9]
layers[i] = new Layer
width: 200
height: 200
i + 1

3 Comments

Koen Bok

Check the snippets for Collections.

Gavin McFarland

Ah perfect. Can I now target an individual layer? For example if I wanted to change the background colour of one layer could I type something like:

cellLayer[5].backgroundColor = "green"

Aurélien Foutoyet

Maybe this ?

objectlist = ["layer1","layer2","layer3","layer4","layer5","layer6","layer7","layer8","layer9"]
bgColor = ["#4527A0","#512DA8","#5E35B1","#673AB7","#7E57C2","#9575CD","#B39DDB","#D1C4E9","#EDE7F6"]
xposition = [20,50,80,110,140,170,200,230,260]

count = 0

for i in objectlist
square = new Layer
square.name = i
square.x = xposition[count]
square.backgroundColor = bgColor[count]

count++

Read the entire post on Facebook