The following block of code does almost what I want it to do except for one important thing. Any help would be greatly appreciated
categories.forEach (cat,i) ->
mainCat= categ[i] = new Layer
categ[i].on Events.Click, ->
if categ[i].states.current is "on"
if categ[!=i].states.current is "on"
You have to loop over all the objects in
categ to and then check if they are the same as the layer that has been clicked on, to switch them on or off.
The same holds for setting the opacity for a layer in another array, but then you should use the index of the loop to look the layer up:
categ[i].on Events.Click, -> for l, index in categ if categ[i] == l l.states.switch("on") cards[index].opacity = 1 else l.states.switch("off") cards[index].opacity = 0
A full prototype with this at work, can be found here: http://share.framerjs.com/2yg7ix83yv1l/ I've replaced the images by background colors to make the layers visible.