简体   繁体   English

AS3-从GESTURE_ZOOM中的缩小检测放大

[英]AS3 - detect Zoom In from Zoom Out in GESTURE_ZOOM

I need to find a way to simply distinguish if the user has Zoomed IN or Zommed OUT, in AS3. 我需要找到一种方法来简单地区分用户是AS3中的Zoomed IN还是Zommed OUT。

It is not about scaling up or down a picture. 这与放大或缩小图片无关。 I want to let user Zoom in on a text to make it larger (FontSize++) or Zoom out on it to make it smaller (FontSize--). 我想让用户放大文本以使其变大(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
}

Kind Regards, Ali 亲切的问候,阿里

I found the answer by creating an experimental application and Try and Error. 我通过创建实验性应用程序和“尝试和错误”找到了答案。

To inform users that may have similar questions in the future, when we pinch the screen, in order to determine whether the zoom is going inward or outward, to execute a function based on that, we may use scaleX or scaleY, and seem there is no difference between these 2 in this case! 为了通知用户将来可能会有类似的问题,当我们捏屏幕时,为了确定缩放是向内还是向外,执行基于此的功能,我们可以使用scaleX或scaleY,并且似乎有在这种情况下,这2个之间没有区别!

As a result: 结果是:

  • If e.scaleX or e.scaleY was greater than 1, that is, zoom in. 如果e.scaleX或e.scaleY大于1,则放大。
  • If e.scaleX or e.scaleY was smaller than 1, that is, zoom out. 如果e.scaleX或e.scaleY小于1,即缩小。

Here is the code: 这是代码:

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

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM