资源描述:
《flash多点触摸屏程序教程》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、〃这段代码用来显示每个触点下面的小红圈packageapp.demo.MyTouchApp{//addsacirclewhereyoutouch(noresize)importflash.display戶;importflash.events.*;importflash.net.*;importflash.geom.*;publicclassMyTouchAppextendsSprite{publicfunctionMyTouchAppO(//connecttoTUIOTUIO.init(this;lo
2、calhosf,3000;*,true);trace(nMyTouchAppInitialized11);//-addEventListener(TouchEvent.MOUSE_DOWN,touchDown);//runtouchdown,whentouched}publicfunctiontouchDown(e:TouchEvent):void{varcurPt:Point=parent.globalToLocal(newPoint(e.stageX,e.stageY));//converttouc
3、hpointstox,yvarcircle:Sprite=newSprite();//createanewspritecircle.graphics.lineStyle(10,OxffOOOO);//setlinewidthtolOpxandredcircle.graphics.drawCircle(0,0,40);//drawa40pxcirclecircle.x=curPl.x;//putitwheretouchis(xcord)circle.y=curPt.y;//putitwheretouchi
4、s(ycord)addChild(circle);//addthecirclewheretouchhappened〃这段代码允许你缩放舞台以及让触点下面出现小红圈〃下面的代码只是继承自RotatableScalable类。里面的内容只针对上述讲的东西,因为每个App构造函数不同。packageapp.demo.MyTouchApp{importflash-display.*;importflash.events.*;importflash.net.*;importflash.geom.*;importa
5、pp.core.action.RotatableScalable;publicclassMyTouchAppextendsRotatableScalable{//allowsittobescaledaroundpublicfunctionMyTouchAppO{//connecttoTUIOTUIO.init(this/localhost3000,",true);trace(nMyTouchAppInitializedH);//addEventListener(TouchEvent.MOUSE_DOW
6、N,touchDown);//runtouchdown,whentouched}publicfunctiontouchDown(e:TouchEvent):void{varcurPt:Point=parent.globalToLocaI(newPoint(e.stageX,e.stageY));//converttouchpointstox,yvarcircle:Sprite=newSprite();//createanewspritecircle.graphics.lineStyle(10,Oxff(
7、)O()O);//setlinewidthtolOpxandredcircle.graphics-drawCircle(0,0,40);//drawa40pxcirclecircle.x=curPt.x;//putitwheretouchis(xcord)circle.y=curPt.y;//putitwheretouchis(ycord)addChild(circle);//addthecirclewheretouchhappened}〃这段代码的作用是使你在触摸的时候,手指下面出现红色的涟漪(不支持
8、选择和缩放的时候出现这个效果)packageapp.demo.MyTouchApp{importflash.events.TUIO;//allowstoconnecttotouchlib/tbetaimportflash.display.*;importflash.events.*;importflash.geom.*;//neededforcurPt;publicclassMyTouchAppextendsSprite{varripple