Search code examples
androidflashscrollmovieclip

Make scroll on Flash CS for an Android App


i'm new here. I'm tryng to make a scroll in flash using GESTURE_PAN but the problem is when i scroll the movieclip and when the last part of the movieclip is on the stage in want to stop the scroll and i can't do that. I'm using Multitouch.inputMode = MultitouchInputMode.GESTURE. Can someone help me?

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;
}

Solution

  • If your movieclip is directly on the stage, something like this should work

    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;  
    }
    

    But you probably would have to put more effort into it if you want to support different screen orientations (stageHeight wont give you accurate reading).

    For getting more accurate reading of screen dimension, I recommend this class:

    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;
            }
        }