簡體   English   中英

在Flash手勢中縮放縮放

[英]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);

}

捏縮放手勢。

您還需要檢查xy屬性。 如果MovieClip的位置超出了Stage范圍,則需要更正它們。

如果您正在使用Classes ,並且MAX_ZOOMMIN_ZOOMconstants ,則建議像它們一樣聲明它們。 此代碼假定你有你的MovieCliproot ,要保持它的內部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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM