Flash Player右键菜单终于可以取消了,我等了十几年……

  • 本站文章除注明转载外,均为本站原创或者翻译。
  • 本站文章欢迎各种形式的转载,但请18岁以上的转载者注明文章出处,尊重我的劳动,也尊重你的智商;
  • 本站部分原创和翻译文章提供markdown格式源码,欢迎使用文章源码进行转载;
  • 本博客采用 WPCMD 维护;
  • 本文标题:Flash Player右键菜单终于可以取消了,我等了十几年……
  • 本文链接:http://zengrong.net/post/1551.htm

昨天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

泪奔中……

Get Adobe Flash
player

源码:

package
{
import flash.display.Sprite;
import flash.display.StageDisplayState;
import flash.events.MouseEvent;
import flash.text.TextField;

/**
 * Flash Player鼠标右键支持
 * @author zrong(zengrong.net)
 * 创建日期:2012-02-28
 */
[SWF(width=500,height=400)]
public class RightClick extends Sprite
{
    public function RightClick()
    {
        _traceTF = createTF();
        _traceTF.width = this.stage.stageWidth*.5;
        _traceTF.height = this.stage.stageHeight;
        _traceTF.text = '左键全屏观察鼠标锁定效果。右键取消全屏。\n';
        this.addChild(_traceTF);

        _locTF = createTF();
        _locTF.width = 100;
        _locTF.height = this.stage.stageHeight;
        _locTF.x = 400;
        this.addChild(_locTF);

        this.stage.doubleClickEnabled = true;
        this.stage.addEventListener(MouseEvent.CLICK, handler_mouseEvent);
        this.stage.addEventListener(MouseEvent.RIGHT_CLICK, handler_mouseEvent);
        this.stage.addEventListener(MouseEvent.MOUSE_MOVE, handler_mouseMove);
    }

    private var _traceTF:TextField;
    private var _locTF:TextField;

    private function createTF():TextField
    {
        var __tf:TextField = new TextField();
        __tf.selectable = false;
        __tf.mouseEnabled = false;
        __tf.wordWrap = true;
        return __tf;
    }

    private function handler_mouseMove($evt:MouseEvent):void
    {
        showLoc($evt.movementX, $evt.movementY);
    }

    private function handler_mouseEvent($evt:MouseEvent):void
    {
        showTrace($evt.type);
        if($evt.type == MouseEvent.CLICK)
        {
            this.stage.displayState = StageDisplayState.FULL_SCREEN;
            this.stage.mouseLock = true;
        }
        else
        {
            this.stage.displayState = StageDisplayState.NORMAL;
        }
        showTrace('fullscreen:'+this.stage.displayState);
    }

    private function showTrace($msg:String):void
    {
        _traceTF.appendText($msg + '\n');
        _traceTF.scrollV = _traceTF.maxScrollV;
    }

    private function showLoc($x:Number, $y:Number):void
    {
        _locTF.appendText($x+','+$y+'\n');
        _locTF.scrollV = _locTF.maxScrollV;
    }
}
}