You could either store its name in an array (target.name) and do a conditional when it’s clicked again, or you could just setup individual listeners for each button.
Yes I can do a conditional to check whether it was clicked before or not you said that the other option souds better.
I am not a hard coder like you I am trying to write efficient code can you please tell me which approach is better because If I assign individual listeners to each button and lets suppose I have 50 buttons then wont it be inefficient?
One more thing can you please tell me that whether you have made your website in AS2 or AS3 and what design programme you use to design your backgrouds and art? Thanks
I like the idea of 50 listeners better than conditionals tbh, just for code clarity. They can all use the same callback as well, so you can just loop the listeners out.
something like this (warning, browser code :P)
`
for (var i:int = 0; i < numButtons; i++) {
_buttonArray*.addEventListener(MouseEvent.CLICK, myCallback);
};
function myCallback(e:MouseEvent):void {
e.currentTarget.removeEventListener(MouseEvent.CLICK, myCallback);
};
`
My website has a few years on it, and it was made in AS2. As for design programs, there’s really no art going on there it’s just a few gradients and fonts