マウスホイールの検出

マウスホイールの検出やってみました。

外部packageとフレーム内両方書いてみました。


■外部packageバージョン

    package {
        
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        
        public class MyMouseWheel extends Sprite
        {
            public function MyMouseWheel()
            {
                stage.addEventListener( MouseEvent.MOUSE_WHEEL , onWheel );
            }
            
            public function onWheel( event:MouseEvent )
            {
                // 上下検出
                // The number of lines that that each notch on the mouse wheel represents.
                // Excite直訳 : それがホイールが表すマウスの上にそれぞれ刻み目をつける線の数。
                trace( event.delta );
            }
        }
    }

■フレーム内バージョン

以下を1フレームに書けば動作します。

    stage.addEventListener( MouseEvent.MOUSE_WHEEL , onWheel );

    function onWheel( event:MouseEvent ){
        // 上下検出
        // The number of lines that that each notch on the mouse wheel represents.
        // Excite直訳 : それがホイールが表すマウスの上にそれぞれ刻み目をつける線の数。
        trace( event.delta );
    }

コメントは受け付けていません。