private static var isShake:Boolean = false;
public static function shake(dis:DisplayObject,times:uint = 2,offset:uint = 4,speed:uint = 32):void {
if(isShake) {
return;
}
isShake = true;
var point:Point = new Point(dis.x,dis.y);
var offsetXYArray:Array = [0,0];
var num:int = 0;
var u:int = setInterval(function():void {
offsetXYArray[num%2] = (num++)%4<2 ?0:offset;
if(num>(times*4 + 1)){
clearInterval(u);
num = 0;
isShake = false;
}
dis.x = offsetXYArray[0] + point.x;
dis.y = offsetXYArray[1] + point.y;
},speed);
}
private static var isShake:Boolean = false;
public static function shake(dis:NativeWindow,times:uint = 2,offset:uint = 4,speed:uint = 32):void {
if(isShake) {
return;
}
isShake = true;
var point:Point = new Point(dis.x,dis.y);
var offsetXYArray:Array = [0,0];
var num:int = 0;
var u:int = setInterval(function():void {
offsetXYArray[num%2] = (num++)%4<2 ?0:offset;
if(num>(times*4 + 1)){
clearInterval(u);
num = 0;
isShake = false;
}
dis.x = offsetXYArray[0] + point.x;
dis.y = offsetXYArray[1] + point.y;
},speed);
}