[英]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.