0

我是新来的。我正在尝试使用 GESTURE_PAN 在 Flash 中进行滚动,但问题是当我滚动影片剪辑时,当影片剪辑的最后一部分在舞台上想要停止滚动时,我不能这样做。我正在使用 Multitouch.inputMode = MultitouchInputMode.GESTURE。有人能帮我吗?

Multitouch.inputMode = MultitouchInputMode.GESTURE;
movieClip_1.addEventListener(TransformGestureEvent.GESTURE_PAN, fl_PanHandler_4);
function fl_PanHandler_4(event:TransformGestureEvent):void
{
event.currentTarget.y += event.offsetY;
}
4

1 回答 1

0

如果你的电影剪辑直接在舞台上,这样的事情应该可以工作

Multitouch.inputMode = MultitouchInputMode.GESTURE;
movieClip_1.addEventListener(TransformGestureEvent.GESTURE_PAN, fl_PanHandler_4);
function fl_PanHandler_4(event:TransformGestureEvent):void
{
   event.currentTarget.y += event.offsetY;
            if(event.currentTarget.y + event.currentTarget.height < stage.stageHeight)
               event.currentTarget.y = stage.stageHeight - event.currentTarget.height; 

            if (event.currentTarget.y > 0)
               event.currentTarget.y = 0;  
}

但是如果你想支持不同的屏幕方向,你可能需要付出更多的努力(stageHeight 不会给你准确的阅读)。

为了更准确地读取屏幕尺寸,我推荐这个类:

import flash.display.Stage;

    public class Oriented
    {
        /**
         * Returns the full screen width assuming orientation is landscape
         */
        public static function landscapeScreenWidth( stage:Stage ):int
        {
            return stage.fullScreenWidth > stage.fullScreenHeight ? stage.fullScreenWidth : stage.fullScreenHeight;
        }
        /**
         * Returns the full screen height assuming orientation is landscape
         */
        public static function landscapeScreenHeight( stage:Stage ):int
        {
            return stage.fullScreenHeight > stage.fullScreenWidth ? stage.fullScreenWidth : stage.fullScreenHeight;
        }
        /**
         * Returns the full screen width assuming orientation is portrait
         */
        public static function portraitScreenWidth( stage:Stage ):int
        {
            return stage.fullScreenWidth < stage.fullScreenHeight ? stage.fullScreenWidth : stage.fullScreenHeight;
        }
        /**
         * Returns the full screen height assuming orientation is portrait
         */
        public static function portraitScreenHeight( stage:Stage ):int
        {
            return stage.fullScreenHeight < stage.fullScreenWidth ? stage.fullScreenWidth : stage.fullScreenHeight;
        }
    }
于 2013-07-05T09:49:18.457 回答