About Air multi-touch Development

Source: Internet
Author: User

Directory:

About flash multi-touch development <Basic> about flash multi-touch development-traffic <Case Study>

 

This topic aims to develop a map case that supports multi-touch. As progress notes only

 

 

 

 

 

import flash.events.TransformGestureEvent; import flash.events.TouchEvent;import flash.text.TextField;  var pointA_id:Number=0;var pointB_id:Number=0; addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);addEventListener(TouchEvent.TOUCH_END, onTouchEnd);addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove); addEventListener(TransformGestureEvent.GESTURE_ROTATE,onRotate)addEventListener(TransformGestureEvent.GESTURE_ZOOM,onZoom)addEventListener(TransformGestureEvent.GESTURE_PAN,onPan)addEventListener(TransformGestureEvent.GESTURE_SWIPE,onSwipe)  function onRotate(e:TransformGestureEvent):void{ _txt.text="rotate:"+e.rotation container.rotation+=e.rotation  } function onZoom(e:TransformGestureEvent):void{ _txt.text="scaleX:"+e.scaleX+"\n"+"scaleY:"+e.scaleY; if(e.scaleX==0 && e.scaleY==0)return;   var scale:Number=(e.scaleX>=e.scaleY) ? e.scaleX : e.scaleY; scale=fixNumber(scale)   var minS:Number=0.2; var maxS:Number=1;   var tempScale=fixNumber(container.photo_mc.scaleX)*scale; tempScale=fixNumber(tempScale)   if(tempScale<minS) tempScale=minS; if(tempScale>maxS) tempScale=maxS;   container.photo_mc.scaleX=container.photo_mc.scaleY=tempScale;  } function onPan(e:TransformGestureEvent):void{ _txt.text="offsetX:"+e.offsetX+"\n"+"offsetY:"+e.offsetY; container.x+=e.offsetX; container.y+=e.offsetY;} function onSwipe(e:TransformGestureEvent):void{ //trace("SWIPE")} function onTouchBegin(e:TouchEvent):void{   if(pointA_id==0){  pointA_id=e.touchPointID  updatePointInfo(e.touchPointID,e.stageX,e.stageY,a_txt) }else{  pointB_id=e.touchPointID  updatePointInfo(e.touchPointID,e.stageX,e.stageY,b_txt) }} function onTouchMove(e:TouchEvent):void{ if(pointA_id==e.touchPointID){  updatePointInfo(e.touchPointID,e.stageX,e.stageY,a_txt) }else{  updatePointInfo(e.touchPointID,e.stageX,e.stageY,b_txt) }  }function onTouchEnd(e:TouchEvent):void{ if(pointA_id==e.touchPointID){  pointA_id=0;  clearPointInfo(a_txt) }else{  pointB_id=0  clearPointInfo(b_txt) }  } function updatePointInfo(id:Number,x:Number,y:Number,_txt:TextField):void{ var str:String=""; str="PointID: "+id+"\n"; str+="X: "+x+"\n"; str+="Y: "+y; _txt.text=str;} function clearPointInfo(_txt:TextField):void{ _txt.text="PointID: --\n"+"X: --\n"+"Y: --";}function fixNumber(n:Number):Number{ return int(n*100)/100;}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.