如果你的影片剪輯是直接在舞臺上,這樣的事情應該工作
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;
}
}
非常感謝這owsome和完美的工作!你是我的英雄!! –