Compare 2 enum variables method?

I simply want to check whether the state has been changed, like this:

var currentState:states;
var lastState:states;

if(lastState != currentState){
   print("state changed");
   lastState = currentState;
}

But I get error, it seems this comparison is somehow wrong? but how to correct this comparison.

Regards,

I assume you didn’t set the flags on the enum.

Try comparing the ints of the enum.

var currentState:states;
var lastState:states;

if((int)lastState != (int)currentState){
   print("state changed");
   lastState = currentState;
}