目录:
关于flash多点触控开发<基础篇>
关于flash多点触控开发-交通 <案例篇>
此专题目的:开发支持多点触控的地图案例。仅仅作为进度笔记
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; }