import flash.display.Sprite; import flash.events.MouseEvent; //创建和引用Sprite类的实例 var test:Sprite =new Sprite(); //定义绘制样式 test.graphics.beginFill(0xff8922,1); //绘制圆形 test.graphics.drawCircle(200,200,100); //添加到显示列表中 stage.addChild(test); //允许使用双击 test.doubleClickEnabled=true; //注册双击事件的侦听器 test.addEventListener(MouseEvent.DOUBLE_CLICK,receiver); //定义侦听器函数 function receiver(e:MouseEvent):void {  var test:Sprite =new Sprite(); test.graphics.beginFill(0xff0000,1); test.graphics.drawCircle(300,300,50); stage.addChild(test); }

 

Sprite 类的实例是双击事件的发送者,当用户在此显示实例中双击时,实例就发出 双击事件,函数receiver()收到事件后,就执行函数体内的代码。

MouseEvent  类的部分属性 stageX      鼠标指针在舞台中的x坐标 stageY      鼠标指针在舞台中的y坐标 buttonDown  是否按下鼠标 ctrlKey     ctrl键是否可用

 

posted on 2012-11-09 00:01  才美  阅读(190)  评论(0编辑  收藏  举报