请您先登录,才能继续操作
浏览 3425 次
锁定老帖子 主题:自己开发的IOS上的多点触摸程序
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-12-20
http://twitter.com/#!/jinwyp import flash.events.TouchEvent; import flash.ui.Multitouch; import flash.ui.MultitouchInputMode; import flash.display.Sprite; Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT; var text1:String; var text2:String; var text3:String; var touchtotal:int = 0; var touchMoveID:int = 0; if (Multitouch.supportedGestures) { text1 = "● SupportsGesture, Support " + Multitouch.maxTouchPoints.toString() + " MaxTouchPoint "; } else { text1 = "● No supports Gesture "; } if (Multitouch.supportsGestureEvents) { text2 = "SupportsGestureEvents "; } else { text2 = "No supports GestureEvents "; } if (Multitouch.supportsTouchEvents) { text3 = "SupportsTouchEvents"; } else { text3 = "No supports TouchEvents"; } mytext1.text = text1 + text2 + text3; startbutton.addEventListener(TouchEvent.TOUCH_TAP, taphandler); function taphandler(evt:TouchEvent): void { removeChild(startbutton); removeChild(group1); removeChild(group2); stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin); } function onTouchBegin(eBegin:TouchEvent) { touchtotal = touchtotal + 1; mytext2.text = "● You have touched " + touchtotal + "points"; touchMoveID = eBegin.touchPointID; var ball1:Sprite = new ball(); ball1.x = eBegin.stageX - 35; ball1.y = eBegin.stageY - 35; ball1.name = "ball" + touchMoveID; addChild(ball1); stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove); stage.addEventListener(TouchEvent.TOUCH_END, onTouchEnd); //eBegin.target.startTouchDrag(eBegin.touchPointID, false, getRect(this)); //var myline:Sprite = new Sprite(); //myline.graphics.lineStyle(2,rgb(),1); //myline.graphics.moveTo(-500, 20); //myline.graphics.lineTo(500,20); //myline.graphics.moveTo(20, -1000); //myline.graphics.lineTo(20,1000); //myline.name = "myline" + touchtotal.toString(); //eBegin.target.addChild(myline); } function onTouchMove(eMove:TouchEvent) { getChildByName("ball" + eMove.touchPointID).x = eMove.stageX - 35; getChildByName("ball" + eMove.touchPointID).y = eMove.stageY - 35; //eEnd.target.stopTouchDrag(eEnd.touchPointID); //eEnd.target.removeChildAt(1); } function onTouchEnd(eEnd:TouchEvent) { var j:int = touchtotal; touchtotal = touchtotal - 1; mytext2.text = "● You have touched " + touchtotal + "points" ; removeChild(getChildByName("ball" + eEnd.touchPointID)); //stage.removeEventListener(TouchEvent.TOUCH_MOVE, onTouchMove); //stage.removeEventListener(TouchEvent.TOUCH_END, onTouchEnd); } //function rgb():uint //{ //return (Math.random() * 0xffffff + 0xff000000); //} color1.addEventListener(TouchEvent.TOUCH_TAP, colorfunc1); function colorfunc1(evt:TouchEvent): void { var colorbox:colorbox1 = new colorbox1(); addChild(colorbox); colorbox.addEventListener(TouchEvent.TOUCH_TAP, colorboxremovefunc); } function colorboxremovefunc(evt:TouchEvent): void { evt.target.removeEventListener(TouchEvent.TOUCH_TAP, colorboxremovefunc); removeChild(getChildByName(evt.target.name)); } color2.addEventListener(TouchEvent.TOUCH_TAP, colorfunc2); function colorfunc2(evt:TouchEvent): void { var colorbox:colorbox2 = new colorbox2(); addChild(colorbox); colorbox.addEventListener(TouchEvent.TOUCH_TAP, colorboxremovefunc); } color3.addEventListener(TouchEvent.TOUCH_TAP, colorfunc3); function colorfunc3(evt:TouchEvent): void { var colorbox:colorbox3 = new colorbox3(); addChild(colorbox); colorbox.addEventListener(TouchEvent.TOUCH_TAP, colorboxremovefunc); } color4.addEventListener(TouchEvent.TOUCH_TAP, colorfunc4); function colorfunc4(evt:TouchEvent): void { var colorbox:colorbox4 = new colorbox4(); addChild(colorbox); colorbox.addEventListener(TouchEvent.TOUCH_TAP, colorboxremovefunc); } color5.addEventListener(TouchEvent.TOUCH_TAP, colorfunc5); function colorfunc5(evt:TouchEvent): void { var colorbox:colorbox5 = new colorbox5(); addChild(colorbox); colorbox.addEventListener(TouchEvent.TOUCH_TAP, colorboxremovefunc); } color6.addEventListener(TouchEvent.TOUCH_TAP, colorfunc6); function colorfunc6(evt:TouchEvent): void { var colorbox:colorbox6 = new colorbox6(); addChild(colorbox); colorbox.addEventListener(TouchEvent.TOUCH_TAP, colorboxremovefunc); } color7.addEventListener(TouchEvent.TOUCH_TAP, colorfunc7); function colorfunc7(evt:TouchEvent): void { var colorbox:colorbox7 = new colorbox7(); addChild(colorbox); colorbox.addEventListener(TouchEvent.TOUCH_TAP, colorboxremovefunc); } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |