实现双击鼠标事件功能
用其它事件都可以的,把MouseEvent.DOUBLE_CLICK改成MouseEvent.MOUSE_WHEEL也可以触发,双击也可以触发.
复制内容到剪贴板代码:
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class DrawApp extends Sprite
{
public function DrawApp()
{
init();
}
private function init():void{
stage.doubleClickEnabled = true;
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUpHandler);
stage.addEventListener(MouseEvent.DOUBLE_CLICK, onMouseDCHandler);
}
private function onMouseDownHandler(e:MouseEvent):void{
graphics.moveTo(mouseX, mouseY);
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveHandler);
}
private function onMouseUpHandler(e:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveHandler);
}
private function onMouseMoveHandler(e:MouseEvent):void{
graphics.lineTo(mouseX, mouseY);
}
private function onMouseDCHandler(e:MouseEvent):void{
graphics.lineStyle(1);
graphics.clear();
}
}
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |