【www.gdgbn.com--鼠标特效】

判断具体按钮的按下状态

import flash.geom.Point
var __pointOld:Point=new Point(mouseX,mouseY)//获取鼠标初始位置
this.addEventListener("enterFrame",enterHandler)//注册真循环事件
function enterHandler(e:Event){
        var pointNew:Point=new Point(mouseX,mouseY)
        var step:Number=Point.distance(pointNew,__pointOld)//求每真移动距离
        trace(step*stage.frameRate)//得出每秒鼠标的移动象素
        __pointOld=pointNew//新值换旧值
}

 

package
{
        import flash.display.Stage;
        import flash.events.KeyboardEvent;
       
        public class PopKeys
        {
                static private var state: Array = new Array();
               
                static public function initStage( stage: Stage ): void
                {
                        stage.addEventListener( KeyboardEvent.KEY_DOWN, onKeyDown );
                        stage.addEventListener( KeyboardEvent.KEY_UP, onKeyUp );
                }
               
                static public function isDown( code: uint ): Boolean
                {
                        return state[ code ] == true;
                }
               
                static private function onKeyDown( event: KeyboardEvent ): void
                {
                        state[ event.keyCode ] = true;
                }
               
                static private function onKeyUp( event: KeyboardEvent ): void
                {
                        state[ event.keyCode ] = false;
                }
        }
}

本文来源:http://www.gdgbn.com/wangyetexiao/15714/