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

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

Hey everyone,I got a problem with new version Framer...
I try to setting something or binding event in layer's sublayers use for-loop,but something wrong...It will always run the last element in for-loop.Is it a bug ? or I miss something? Thanks~^^

my share project :

code is very simple:

LayerStack=new Layer
.width: Screen.width

layer1=new Layer
.width: 100
.height: 100
.backgroundColor: Utils.randomColor()
.parent: LayerStack

layer2=new Layer
.width: 100
.height: 100
.backgroundColor: Utils.randomColor()
.parent: LayerStack

for item in LayerStack.subLayers
.item.on Events.Click,->


Niels van Hoorn

You ran into a classic example of misunderstanding scope ;)
You can read up on it here:

Your current problem can be most easily fixed by using 'this' or its synonym '@' instead of item:
item.onClick ->
. print @name


Thanks very much, Niels. ^^

Read the entire post on Facebook