he wasnt in a fish tank, he was in a chameleon cage made specifiacly for them with vents under the doors and mesh at the top. and it was a uvb bulb.so he was heated and we had a thermometer.
Please, don't take the comments too hard, people are just trying to help you and sometimes making assumptions that turn out wrong (as in the case with the aquarium assumption). In regards to UVB bulb - you didn't mention that when describing your lighting setup, you just wrote it was 50W, you didn't mention what brand it was or what was the UVB percentage (usually it is 5.0 or 10.0), that is why Carol decided you had no UVB source.
From what I can see, first of all your chameleon was very young when you got him - 2 weeks old is too young really, especially if this was your first chameleon. They are very fragile at that age, and normally it is not advised to buy or sell them until they've reached at least 2-3 month. Where was it that you bought him?
Your feeding was sub-optimal I would say. Mealworms contain close to none nutritional value, they are mostly fat really, that's all, and plus you say he never took the ones that were dusted in calcium. Also you did not mention using any kind of vitamin supplement. That means that he probably was not getting the nutrients, minerals and vitamins that he needed to develop and grow properly. Chameleons need a variety of feeders, it is advised to use crickets, roaches, hornworms and silkworms as main feeders, and dusting with calcium at every feeding is of paramount importance, because chameleons need calcium not only for their bones, but also for many other bodily processes, including proper muscle function, breathing, etc.
There could have been subtle signs indicating that he was not doing well before he started getting dark and closing his eyes, that you have not noticed simply because of lack of experience - there is nothing wrong with that, I have tried it myself, it happens, because chameleons are challenging creatures to keep.
Finally, there might have been some kind of a genetic defect, or maybe his mum was not cared for properly while she was carrying eggs, which resulted in him being weak or even ill, and in that case there was really not much you could have done.
Do you have any pictures of him that were taken after some time in your care or maybe shortly before he passed away? Also, maybe you have a picture of the enclosure itself? That could really help. There is a possibility that even though you had leaves and branches in his enclosure, there was still not enough places for him to hide and get his privacy - I am mentioning that because you wrote yourself that he started getting dark and lack of hiding places can stress chameleons very much.
And please, don't take any of this as an attack on yourself. I believe with all my heart, that you were doing the best you could for your little friend. I have lost a chameleon myself and I know how it hurts... I would however like to help you figure out what went wrong, so that you can enjoy keeping these wonderful critters in future
JUlija