Adobe Air for Android中的鼠标滚轮事件(尝试编写Adobe Native Extension)

时间:2014-02-27 04:57:14

标签: android actionscript-3 air mousewheel air-native-extension

我正在尝试编写一个Adobe air原生扩展来捕获android上的鼠标滚轮。

当我将其作为本机应用程序进行测试时,Android正在获取鼠标滚轮事件。

但是当我尝试将该代码打包为本机扩展时,我没有得到该事件。

我遵循tutorial

我可以在当前视图中添加一个监听器吗?

我错过了其他什么吗?

Android中有鼠标滚轮的鼠标滚轮扩展吗?

    public class OpenAppANE extends Activity implements FREExtension, OnTouchListener {
        public void startMouseEvent()
        {
            LinearLayout touchLayout = new LinearLayout(this);
          // set layout width 30 px and height is equal to full screen
          LayoutParams lp = new LayoutParams(30, LayoutParams.MATCH_PARENT);
          touchLayout.setLayoutParams(lp);
          // set color if you want layout visible on screen
        //  touchLayout.setBackgroundColor(Color.CYAN);
          // set on touch listener
          touchLayout.setOnTouchListener(this);

          // fetch window manager object
          WindowManager mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

          // set layout parameter of window manager

          WindowManager.LayoutParams mParams = new WindowManager.LayoutParams(30,
                    // width of layout 30 px
                  WindowManager.LayoutParams.MATCH_PARENT, // height is equal to full screen
                        WindowManager.LayoutParams.TYPE_PHONE, // Type Phone, These are non-application windows providing user interaction with the phone (in particular incoming calls).
                        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, // this window won't ever get key input focus 
                        PixelFormat.TRANSLUCENT);     
                mParams.gravity = Gravity.LEFT | Gravity.TOP;  
                Log.i("TAG", "add View");

              mWindowManager.addView(touchLayout, mParams);

        }
            @Override
            public boolean onGenericMotionEvent(MotionEvent event) {
             Toast.makeText(appContext, "inside onGenericMotionEvent" , Toast.LENGTH_SHORT ).show();
    }
}

1 个答案:

答案 0 :(得分:0)

Air有一个MOUSE_WHEEL监听器。

我会用

stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheelEvent);

听老鼠轮事件。应该工作正常。

所有鼠标事件都适用于Android Native。

也使用'delta' 设置鼠标滚轮上每个凹口所代表的行数。 退房:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/InteractiveObject.html#event:mouseWheel