小试rotation

来源:互联网 发布:淘宝第三方公司 编辑:程序博客网 时间:2024/06/15 00:11

AS3.0 中指示 DisplayObject 实例距其原始方向的旋转程度,一般用rotation来做这样的旋转效果,下面是我小试一下rotation中的rotationY即以Y轴为中心旋转的实例:

//是否反转
var isDown:Boolean = false;
//一直旋转
addEventListener(Event.ENTER_FRAME,enterFrame);
//侦听鼠标移到金币上,停止金币的旋转
addEventListener(MouseEvent.MOUSE_OVER,mouseOverEvt);
//侦听鼠标移出金币,回复金币的旋转
addEventListener(MouseEvent.MOUSE_OUT,mouseOutEvt);
//侦听鼠标点击金币,使金币反向绕Y轴旋转
addEventListener(MouseEvent.MOUSE_DOWN,mouseDownEvt);

 

function enterFrame(event:Event):void
{
    gold.gotoAndStop(1);

//gold为元件名
    if(isDown)
        gold.rotationY -= 10;
    else
        gold.rotationY += 10;
}
function mouseOverEvt(event:MouseEvent):void
{
 gold.gotoAndStop(2);//描边金币效果
 removeEventListener(Event.ENTER_FRAME,enterFrame);
 gold.rotationY = 0;
}
function mouseOutEvt(event:MouseEvent):void
{
 gold.gotoAndStop(1);
 addEventListener(Event.ENTER_FRAME,enterFrame);
}
function mouseDownEvt(event:MouseEvent):void
{
 isDown = !isDown;
}

 

简单粗略的写写尔耳,呵呵!

原创粉丝点击