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

What is Framer? Join the Community
Return to index
Daniel Maniés
Posted Aug 10 - Read on Facebook

Hey guys,
I have a small problem I really don't understand and maybe you can help me :)

I designed a navigation bar with 3 links in the design tab. I added another layer around them to have an array of links. To go through the array I used following for-loop:

"for link, i in nav.childrenWithName("links")[0].children"

"link" is the object in the array, "i" is the index and "nav.childrenWithName("links")[0].children" is the array.

Now I want to work with the index in an event, but there the index is always "3". But it should be "0", "1" or "2" like before/after the event.

I added the layer structure and the code sample as an image.

Can someone explain me this odd behavior?

Thank you in advance,
Daniel

3 Comments

Jordan Robert Dobson

it's a scope problem with your loop.

think of it this way... when the loop is done its value should be 3. You would see that if you did a print after the loop.

So when you call the print statement in your mouseOver event... it's also three at that point in time.

You can use do (i) -> in coffeescript to capture it.

Daniel Maniés

Ha! It worked :) Thank you very much Jordan!

Read the entire post on Facebook