Your problem boils down to one major "oops". In your class method that changes the color.... take a look... a CLOSE look at exactly WHAT is getting set with the value of what! Hint.... you are setting the value of the argument with the current value of the int. To research this part, look up some info on "assignment" and I think you'll find the key.
The reason that it works in the second example is that, in the same handler as above, you are returning the value of the argument that you passed in NOT the value of the int. It will always pass back what you passed in.
Read this, take another look at these areas, and I think you'll find your answer!
Says, assign the current value of the variable anIntegerRepresentingColors to the variable newHue and then allow the newHue variable to fall out of scope.