[英]Zoom resize in Flash Gesture
我在缩放方面有限制,因此您可以将缩放比例从100%调整为150%。 但是,我进行缩放,然后平移到缩放的MC的右上角,然后缩小时,MC停留在左侧,MC从屏幕上消失。 我再也看不到MC了。
如何在不进入Stage
情况下缩小MC? 这是我的缩放代码:
function onZoom(e:TransformGestureEvent):void {
var MIN_ZOOM:Number = 1; //minimal zoom percentage 100%
var MAX_ZOOM:Number = 1.5; //maximal zoom percentage 150%
escenario.scaleX *= e.scaleX;
escenario.scaleY *= e.scaleY;
escenario.scaleX = Math.max(MIN_ZOOM, escenario.scaleX);
escenario.scaleY = Math.max(MIN_ZOOM, escenario.scaleY);
escenario.scaleX = Math.min(MAX_ZOOM, escenario.scaleX);
escenario.scaleY = Math.min(MAX_ZOOM, escenario.scaleY);
}
捏缩放手势。
您还需要检查x
和y
属性。 如果MovieClip
的位置超出了Stage
范围,则需要更正它们。
如果您正在使用
Classes
,并且MAX_ZOOM
和MIN_ZOOM
是constants
,则建议像它们一样声明它们。 此代码假定你有你的MovieClip
的root
,要保持它的内部Stage
边界和MovieClip
与1的比例有大小相同的Stage
,改变取决于你的布局的代码。
private const MIN_ZOOM:Number = 1;
private const MAX_ZOOM:Number = 1.5;
private function onZoom(e:TransformGestureEvent):void {
var scale:Number = Math.min(e.scaleX, e.scaleY);
escenario.scaleX *= scale;
// Check if the scale is between the min and max parameters
if(escenario.scaleX > MAX_ZOOM) escenario.scaleX = MAX_ZOOM;
if(escenario.scaleX < MIN_ZOOM) escenario.scaleX = MIN_ZOOM;
escenario.scaleY = escenario.scaleX;
// Check is the MovieClip is inside the Stage bounds
if(escenario.x > 0) escenario.x = 0;
if(escenario.y > 0) escenario.y = 0;
if(escenario.x + escenario.width < escenario.stage.stageWidth) escenario.x = escenario.stage.stageWidth - escenario.width;
if(escenario.y + escenario.height < escenario.stage.stageHeight) escenario.y = escenario.stage.stageHeight - escenario.height;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.