Hi I'm fairly new to javascript and CoffeeScript, so I'm currently working on a prototype and learning the language simultaneously.
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
width:185
height:77
parent:catSelect.content
y:13
x:205*i+20
image:categories[i]
categ[i].states.add
off:
image: categories[i]
on:
image: altCat[i]
categ[i].on Events.Click, ->
categ[i].states.next("on","off")
if categ[i].states.current is "on"
print "true"
Here I have a loop to create category buttons (mainCat) which have 2 states with separate arrays of images attached (categories[] and altCat[]).
I have put this loop in an array, so that now, when i click a category, I can check its state using categ[i], but that's pretty much where my limits are.
Right now this basically treats objects in my categ[] array as a multiple choice, whereas I want it to only let one object in the array be in the "on" state at a time and, once it's in the "on" state, it needs to show a specific row of cards while keeping other rows hidden in another array (call it cards[]) located in a separate layer/div.
i.e. something like:
if categ[!=i].states.current is "on"
categ[!=i].states.switch("off")
cardsRow[!=i].opacity=0
cardsRow[i].opacity=1
Thanks in advance!