AS3 - 检测GESTURE_ZOOM中的缩小放大

时间:2018-05-22 07:13:53

标签: actionscript-3

我需要找到一种方法来简单区分用户是否在AS3中具有Zoomed IN或Zommed OUT。

这不是关于放大或缩小图片。我想让用户放大文本以使其更大(FontSize ++)或缩小它以使其更小(FontSize - )。

myTextBox.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom);
function onZoom(e:TransformGestureEvent):void {
    //if it is zoom in => call fontSizeInc  
    //if it is zoom out => call fontSizeDec
}

亲切的问候,        阿里

1 个答案:

答案 0 :(得分:2)

我通过创建实验性应用程序和Try and Error找到了答案。

为了告知将来可能有类似问题的用户,当我们捏住屏幕时,为了确定缩放是向内还是向外,为了执行基于此的功能,我们可以使用scaleX或scaleY,以及在这种情况下,这两个似乎没有区别!

结果:

  • 如果e.scaleX或e.scaleY大于1,即放大。
  • 如果e.scaleX或e.scaleY小于1,即缩小。

以下是代码:

myTextBox.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom);
function onZoom(e:TransformGestureEvent):void {
 if (e.scaleX > 1) {
  fontSizeInc();
 } else if (e.scaleX < 1) {
  fontSizeDec();    
 }
}

由于