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

What is Framer? Join the Community
Return to index
John Trabelsi
Posted Sep 20 - Read on Facebook

Hi everyone!
Ok I FINALLY did the jump and started using framer. I'll most probably have my team using it as well really soon.

Quick newbie question for which I can't seem to get the answer. When using a FOR loop to create layers, how to you refer to a specific layer and change it's properties independently?

Searching for the answer got me there (screenshot) but as you'll see the dot1.backgroundColor = "red" didn't change the color of the layer.

Thx guys!!


Kees Plattel

Look up the layer.children function (And it's relatives; layer.childrenWithName, layer.siblings, etc...) That should get you going. Here's a direct link to the documentation:

Chris Camargo

`dot1` won't work as you've written, because `dot1` isn't a variable in JavaScript; it's the `name` and `id` of a layer you've created. Since you say `dot = new Layer` in your loop, the only var you have to hook onto is `dot`. In your loop, that var is being reassigned 10 times (because the loop runs 10 times), so by the time that loop is done, `dot` will only refer to the last layer created by the loop.

Here's what I'd do...

John Trabelsi

Thx to you both!! I'll check both of your options and experiment with my new learnings. Can't wait to be good at it! :)

Marc Krenn

Alternative approach plus some additional tricks.

Read the entire post on Facebook