小试rotation

    技术2025-01-26  22

    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;}

     

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

    最新回复(0)