I am having a problem with a basic section of code. I am not sure what I am doing wrong. It could be a logic problem or something action script 3 specific that I have over looked. I am new to action script but not to coding.
Here is the code.
public class Main extends Sprite
{
public var VariableX:Boolean = true;
public function Main():void
{
ChangeVariableXButton.addEventListener(MouseEvent.MOUSE_DOWN, ChangeVariableX);
function ChangeVariableX(event:MouseEvent):void
{
if (VariableX = false)
{
VariableX = true;
trace(VariableX);
}
else
{
VariableX = false;
trace(VariableX);
}
}
}
}
When the ChangeVariableXButton is clicked the boolean VariableX should be changed from its current value to the other one. If the ChangeVariableXButton is clicked repeatedly then a list of true and false should be displayed alternatively in the debug window.
What is happening is that the VariableX is changed to false on the first click and remains false on all subsequent clicks.