Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3:AdobeAIR android中的缩放和平移movieclip_Actionscript 3_Flash_Air - Fatal编程技术网

Actionscript 3 AS3:AdobeAIR android中的缩放和平移movieclip

Actionscript 3 AS3:AdobeAIR android中的缩放和平移movieclip,actionscript-3,flash,air,Actionscript 3,Flash,Air,我正在使用github上的gestouch库 zoomall是我的电影唇,我能够在特定点放大和缩小。 这是我的密码 import org.gestouch.events.GestureEvent; import org.gestouch.gestures.ZoomGesture; var zoom: ZoomGesture*; zoom = new ZoomGesture(zoomall); zoom.addEventListener(org.gestouch.events.GestureE

我正在使用github上的gestouch库

zoomall是我的电影唇,我能够在特定点放大和缩小。 这是我的密码

import org.gestouch.events.GestureEvent;
import org.gestouch.gestures.ZoomGesture;

var zoom: ZoomGesture*;

zoom = new ZoomGesture(zoomall);
zoom.addEventListener(org.gestouch.events.GestureEvent.GESTURE_BEGAN, onGesture);
zoom.addEventListener(org.gestouch.events.GestureEvent.GESTURE_CHANGED, onGesture);

function onGesture(event: org.gestouch.events.GestureEvent): void {

    const gesture: ZoomGesture = event.target as ZoomGesture;

    var matrix: Matrix = zoomall.transform.matrix;
    var transformPoint: Point = matrix.transformPoint(zoomall.globalToLocal(zoom.location));
    matrix.translate(-transformPoint.x, -transformPoint.y);
    matrix.scale(gesture.scaleX, gesture.scaleY);
    matrix.translate(transformPoint.x, transformPoint.y);
    zoomall.transform.matrix = matrix;
}
在这里,我想限制放大和缩小到特定的比例。
我还想平移movieclip(zoomall),它不应该平移到设备屏幕之外。

如果您想尝试flash的全部功能,这些都是非常好的简单教程,可以帮助您解决问题

泛教程 收缩/缩放


希望这能帮助您认识到,通过调用matrix.scale(B,B),您只需执行A*B=C, 其中,A是当前量表,C是结果量表? 因此,如果您不希望C大于最大maxC,则应限制B

B = Math.min(B, maxC / A)
B = Math.max(minC / A, B)
最小值最小值相同:

B = Math.min(B, maxC / A)
B = Math.max(minC / A, B)
因此,您将有:

// assuming you keep the scale ratio
var minS:Number = MIN_SCALE / zoomall.scaleX;
var maxS:Number = MAX_SCALE / zoomall.scaleX;
var s:Number = Math.max(minS, Math.min(gesture.scaleX, maxS));
matrix.scale(s, s);

我们可以看到,您正在更新变换矩阵以缩放和移动对象。限制这种转换的问题是什么?@Pavelfljōt如何给出最小和最大缩放限制?但我的平移问题仍然存在。我知道这个库是你写的,你可以解决我的问题。请告诉我如何“在边界内”(屏幕区域)平移电影剪辑。平移只能用一根手指来完成。我相信你可以用类似的方法来完成边界。问问是否有什么特别的事情会困扰你。我在这上面花了很多时间。你能告诉我解决方法吗?谢谢你的帮助。但是我建议你使用gestouch库,它比这个好得多。