2013-07-04 26 views
0

我是新來的。我嘗試使用GESTURE_PAN在Flash中進行滾動,但問題是當我滾動動畫片段並且動畫片段的最後部分在舞臺上時想停止滾動,而我無法做到這一點。我正在使用Multitouch.inputMode = MultitouchInputMode.GESTURE。有人能幫我嗎?在Flash CS上爲Android應用創建滾動

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

回答

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

非常感謝這owsome和完美的工作!你是我的英雄!! –

相關問題