var lastShake:Number = 0;
var shakeWait:Number = 500;
var acc:Accelerometer = new Accelerometer();
acc.addEventListener(AccelerometerEvent.UPDATE, onAccUpdate);
function onAccUpdate(e:AccelerometerEvent):void
{
if(getTimer() - lastShake > shakeWait && (e.accelerationX >= 1.5 || e.accelerationY >= 1.5 || e.accelerationZ >= 1.5))
{
shakeIt();
lastShake = getTimer();
}
}
function shakeIt()
{
trace("device has been shaked");
}
设备摇动 - 加速度计
ActionScript3
阅读 38
收藏 0
点赞 0
评论 0
评论列表
文章目录