var flag:Boolean = false; myButton.addEventListener('click', function() { flag = !flag; trace(flag); });