[AS3]as3中添加鼠标监听事件
[AS3]as3中添加鼠标监听事件
[AS3]as3中添加鼠标监听事件
- package {
- import flash.display.Sprite;
- import flash.events.MouseEvent;
- public class ExampleApplication extends Sprite {
- private var _sprite:Sprite;//CuPlayer.com提示:申明变量
- public function ExampleApplication( ) {
- _sprite = new Sprite( );
- addChild(_sprite);
- _sprite.graphics.beginFill(0xffffff);
- _sprite.graphics.drawRect(50, 50, 400, 300);//CuPlayer.com提示:画线范围
- _sprite.graphics.endFill( );
- _sprite.addEventListener(MouseEvent.MOUSE_DOWN, ax);
- _sprite.addEventListener(MouseEvent.MOUSE_UP, sk);
- }
- private function ax(event:MouseEvent):void {
- _sprite.graphics.lineStyle(1, 0, 1);
- _sprite.graphics.moveTo(mouseX, mouseY);
- _sprite.addEventListener(MouseEvent.MOUSE_MOVE,yd);
- }
- private function sk(event:MouseEvent):void {
- _sprite.removeEventListener(MouseEvent.MOUSE_MOVE, yd);
- }
- private function yd(event:MouseEvent):void {
- _sprite.graphics.lineTo(mouseX, mouseY);
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...