AS3缓动公式:
sprite.x += (targetX – sprite.x) * easing;//easing为缓动系数变量
sprite.y += (targetY – sprite.y) * easing;

AS3弹性公式:
vx += (targetX – sprite.x) * spring;//spring为弹性系数
vy += (targetY – sprite.y) * spring;
sprite.x += (vx *= friction);//friction为摩擦力
sprite.y += (vy *= friction);

AS3偏移弹性公式:
var dx:Number = sprite.x – fixedX;
var dy:Number = sprite.y – fixedY;
var angle:Number = Math.atan2(dy, dx);
var targetX:Number = fixedX + Math.cos(angle) * springLength;
var targetY:Number = fixedX + Math.sin(angle) * springLength;

AS3向鼠标旋转(或向某点旋转)
dx = mouseX – sprite.x;
dy = mouseY – sprite.y;
sprite.rotation = Math.atan2(dy, dx) * 180 / Math.PI;

AS3波形运动:
public function onEnterFrame1(event:Event):void {
ball.y=centerScale+Math.sin(angle)*range;
angle+=speed;
}

心跳:
public function onEnterFrame1(event:Event):void {
ball.scaleX=centerScale+Math.sin(angle)*range;
ball.scaleY=centerScale+Math.sin(angle)*range;
angle+=speed;
}

AS3圆心旋转:
public function onEnterFrame(event:Event):void {
ball.x=centerX+Math.cos(angle)*radius;
ball.y=centerY+Math.sin(angle)*radius;
angle+=speed;
}

椭圆旋转:
public function onEnterFrame(event:Event):void {
ball.x=centerX+Math.cos(angle)*radiusX;
ball.y=centerY+Math.sin(angle)*radiusY;
angle+=speed;
}
AS3颜色运算得到透明值:
var t:uint=0x77ff8877
var s:uint=0xff000000
var h:uint=t&s
var m:uint=h>>>24
trace(m)
AS3转换为十进制:
trace(hexValue);
AS3十进制转换为十六进制:
decimalValue.toString(16)
AS3颜色提取:
red = color24 >> 16;
green = color24 >> 8 & 0xFF;
blue = color24 & 0xFF;
alpha = color32 >> 24;
red = color32 >> 16 & 0xFF;
green = color32 >> 8 & 0xFF;
blue = color232 & 0xFF;
AS3按位计算得到颜色值:
color24 = red << 16 | green << 8 | blue;
color32 = alpha << 24 | red << 16 | green << 8 | blue;
AS3过控制点的曲线:
// xt, yt is the point you want to draw through
// x0, y0 and x2, y2 are the end points of the curve
x1 = xt * 2 – (x0 + x2) / 2;
y1 = yt * 2 – (y0 + y2) / 2;
moveTo(x0, y0);
curveTo(x1, y1, x2, y2);

AS3右键菜单:
建立右键菜单项:
var cm:ContextMenu=new ContextMenu();
cm.hideBuiltInItems();//隐藏系统菜单(不全隐藏)
cm.builtInItems指向右键菜单的系统项是个ContextMenuBuiltInItems对象
如: cm.builtInItems.print=true;使其打印可选
cm.customItems是个数字指定右键菜单项目
new ContextMenuItem(“菜单1″,false,true,true)建立一个右键菜单项目,必须指定到customItem中,第一个参数为是否上面出现间隔线,第二个为是否禁用,第三个为是否显示;
如: cm.customItems.push(new ContextMenuItem(“hello”,false,false,true))
常用事件:
cm.addEventListener(ContextMenuEvent.MENU_SELECT,function(){trace(“ss”)})//当右键菜单触发时
cm.customItems[i].addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,MenuItemSelectHandler);//当某个选择项触发时e.currentTarget.caption;得到相应的caption

    博视界科技专注于沉浸式全景数字餐厅、全息酒店宴会厅,旨在帮传统餐饮用科技玩跨界,欢迎咨询!

官方网站:www.boseetech.com

联系方式:    

微信联系我:


    【声明】转载本文请注明出处三人行设计,并保留有效链接:AS3常用动画效果公式集合 http://www.srxtuan.com/archives/1077,谢谢!