如果你的电影剪辑直接在舞台上,这样的事情应该可以工作
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;
}
}