Hi! Could someone explain me how I could apply layer.animate to all layers stored in the array instead of the last one? Thanks!
8 Comments
Adria Jimenez
Hello Hugo des Gayets you can use @animate instead of layer.animate as "@" will contain the appropiate layer every time the click is fired. You can see an example of what I mean here: http://share.framerjs.com/c2xtp5i9elqy/
Basically by the time you click layer is equal to the last element in the loop because there aren't any more to set layer to. So you have to use "this" as in this.layer or @.layer.
This refers to the element clicked that calls that function.
Hugo des Gayets
Thanks Jordan Robert Dobson!
Marc Krenn
1. You can get rid of the allLayers.push(layer) by adding every layer to the array at their creation:
'layer = allLayers[i] = new Layer'
2. You can also git rid of the second loop (just remove line 26)! Instead of animating layer ('layer.animate') on Click, use '@.animate' or 'this.animate'.
8 Comments