No need of conditional statement to figure out which direction to toggle a Boolean value.
var iStRue:Boolean; iStRue = !iStRue; trace(iStRue); //true iStRue = !iStRue; trace(iStRue); //false
E: me@sabisin.com | T: +4915168651209
No need of conditional statement to figure out which direction to toggle a Boolean value.
var iStRue:Boolean; iStRue = !iStRue; trace(iStRue); //true iStRue = !iStRue; trace(iStRue); //false
Heres a small snippet to detect shakes on mobile devices with accelerometer:
var lastShake:Number = 0; var shakeWait:Number = 600; var acc:Accelerometer = new Accelerometer(); acc.addEventListener(AccelerometerEvent.UPDATE, onAccUpdate); function onAccUpdate(evt:AccelerometerEvent):void { if(getTimer() - lastShake > shakeWait && (evt.accelerationX >= 1.5 || evt.accelerationY >= 1.5 || evt.accelerationZ >= 1.5)) { sHakeiT(); lastShake = getTimer(); } } function shakeIt() { trace("shakeIt();"); }