Flash Player右键菜单终于可以取消了,我等了十几年……
昨天Adobe发布了 Flash Player 11.2 RC版 ,这意味着伴随着我们十几年的FlashPlayer右键菜单终于可以取消了。
随之而来的还有鼠标坐标锁定功能,睡眠事件支持等等,详细列表看这里:http://labs.adobe.com/technologies/flashplatformruntimes/flashplayer11-2/。
下面这个例子演示了右键支持以及到底什么是鼠标坐标锁定。点击鼠标左键全屏观察鼠标锁定效果。右键取消全屏。
这个例子需要Flash Player 11.2支持,请在这里下载:http://labs.adobe.com/downloads/flashplayer11-2.html
文档支持:http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/index.html
泪奔中……
源码:
1package
2{
3import flash.display.Sprite;
4import flash.display.StageDisplayState;
5import flash.events.MouseEvent;
6import flash.text.TextField;
7
8/**
9 * Flash Player鼠标右键支持
10 * @author zrong(zengrong.net)
11 * 创建日期:2012-02-28
12 */
13[SWF(width=500,height=400)]
14public class RightClick extends Sprite
15{
16 public function RightClick()
17 {
18 _traceTF = createTF();
19 _traceTF.width = this.stage.stageWidth*.5;
20 _traceTF.height = this.stage.stageHeight;
21 _traceTF.text = '左键全屏观察鼠标锁定效果。右键取消全屏。\n';
22 this.addChild(_traceTF);
23
24 _locTF = createTF();
25 _locTF.width = 100;
26 _locTF.height = this.stage.stageHeight;
27 _locTF.x = 400;
28 this.addChild(_locTF);
29
30 this.stage.doubleClickEnabled = true;
31 this.stage.addEventListener(MouseEvent.CLICK, handler_mouseEvent);
32 this.stage.addEventListener(MouseEvent.RIGHT_CLICK, handler_mouseEvent);
33 this.stage.addEventListener(MouseEvent.MOUSE_MOVE, handler_mouseMove);
34 }
35
36 private var _traceTF:TextField;
37 private var _locTF:TextField;
38
39 private function createTF():TextField
40 {
41 var __tf:TextField = new TextField();
42 __tf.selectable = false;
43 __tf.mouseEnabled = false;
44 __tf.wordWrap = true;
45 return __tf;
46 }
47
48 private function handler_mouseMove($evt:MouseEvent):void
49 {
50 showLoc($evt.movementX, $evt.movementY);
51 }
52
53 private function handler_mouseEvent($evt:MouseEvent):void
54 {
55 showTrace($evt.type);
56 if($evt.type == MouseEvent.CLICK)
57 {
58 this.stage.displayState = StageDisplayState.FULL_SCREEN;
59 this.stage.mouseLock = true;
60 }
61 else
62 {
63 this.stage.displayState = StageDisplayState.NORMAL;
64 }
65 showTrace('fullscreen:'+this.stage.displayState);
66 }
67
68 private function showTrace($msg:String):void
69 {
70 _traceTF.appendText($msg + '\n');
71 _traceTF.scrollV = _traceTF.maxScrollV;
72 }
73
74 private function showLoc($x:Number, $y:Number):void
75 {
76 _locTF.appendText($x+','+$y+'\n');
77 _locTF.scrollV = _locTF.maxScrollV;
78 }
79}
80}
- 文章ID:1551
- 原文作者:zrong
- 原文链接:https://blog.zengrong.net/post/flash-context-menu/
- 版权声明:本作品采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 进行许可,非商业转载请注明出处(原文作者,原文链接),商业转载请联系作者获得授权。