iOS设备多点触控??屏幕坏点检测程序代??/a>[代码]
鉴客

日期:2016/7/19 10:29:00 来源:本网整理 阅读:0
http://blog.devdiv.com/ios%E8%AE%BE%E5%A4%87%E5%A4%9A%E7%82%B9%E8%A7%A6%E6%8E%A7%E5%92%8C%E5%B1%8F%E5%B9%95%E5%9D%8F%E7%82%B9%E6%A3%80%E6%B5%8B%E7%A8%8B%E5%BA%8F%E4%BB%A3%E7%A0%81.html

[1].[图片] 运行屏幕截图 跳至 [1] [2]

[2].[代码] [C/C++]代码 跳至 [1] [2]

    import flash.events.TouchEvent;
    import flash.events.MouseEvent;
    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;
    var touchgrouplength:int;
    var touchgroup:Array = new Array();
    var ballgroup:Array = new Array();
    var myline1:Sprite = new Sprite();
    var tempballnum:int;
    var tempflagx:Boolean;
    var tempflagy:Boolean;
    var tempflag:Boolean;
    var color:uint = rgb();
    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);
         stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
         stage.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);
    }
    function onTouchBegin(eBegin:TouchEvent)
    {
         touchtotal = touchtotal + 1;
         mytext2.text = “● You have touched ??+ touchtotal + “points??
         touchMoveID = eBegin.touchPointID;
         tempflagy = (eBegin.stageY > touchbox.y) && (eBegin.stageY < (touchbox.y + touchbox.height));
         tempflagx = (eBegin.stageX > touchbox.x) && (eBegin.stageX < (touchbox.x + touchbox.width));
         tempflag = tempflagy && tempflagx;
         if (tempflag)
         {
             var ball1:Sprite = new ball();
             ball1.x = eBegin.stageX ??35;
             ball1.y = eBegin.stageY ??35;
            ball1.name = “ball??+ touchMoveID.toString();
             ballgroup.push(ball1);
             addChild(ball1);
             touchgroup.push(touchMoveID);
             switch (ballgroup.length)
             {
                 case 0 :
                     break;
                 case 1 :
                     break;
                 case 2 :
                     var myline1:Sprite = new Sprite();
                     myline1.name = “line??+ (ballgroup.length-1);
                     myline1.graphics.clear();
                     myline1.graphics.lineStyle(4, color, 1);
                     myline1.graphics.moveTo(ballgroup[0].x + ballgroup[0].width/2, ballgroup[0].y + ballgroup[0].height/2);
                     myline1.graphics.lineTo(ballgroup[1].x + ballgroup[1].width/2, ballgroup[1].y + ballgroup[1].height/2);
                     addChild(myline1);
                     break;
                 default :
                     var myline2:Sprite = new Sprite();
                     myline2.name = “line??+ (ballgroup.length-1);
                     myline2.graphics.clear();
                     myline2.graphics.lineStyle(4,color, 1);
                     myline2.graphics.moveTo(ballgroup[ballgroup.length-2].x + ballgroup[ballgroup.length-2].width/2, ballgroup[ballgroup.length-2].y + ballgroup[ballgroup.length-2].height/2);
                     myline2.graphics.lineTo(ballgroup[ballgroup.length-1].x + ballgroup[ballgroup.length-1].width/2, ballgroup[ballgroup.length-1].y + ballgroup[ballgroup.length-1].height/2);
                     addChild(myline2);
                     var myline3:Sprite = new Sprite();
                     myline3.name = “line??+ (ballgroup.length);
                     myline3.graphics.clear();
                     myline3.graphics.lineStyle(4,color, 1);
                     myline3.graphics.moveTo(ballgroup[0].x + ballgroup[0].width/2, ballgroup[0].y + ballgroup[0].height/2);
                     myline3.graphics.lineTo(ballgroup[ballgroup.length-1].x + ballgroup[ballgroup.length-1].width/2, ballgroup[ballgroup.length-1].y + ballgroup[ballgroup.length-1].height/2);
                     addChild(myline3);
                     if (ballgroup.length > 3)
                     {
                         removeChild(getChildByName(“line??+ (ballgroup.length-1)));
                     }
             }
         }
    }
    function onTouchMove(eMove:TouchEvent)
    {
         getChildByName(“ball??+ eMove.touchPointID).x = eMove.stageX ??35;
         getChildByName(“ball??+ eMove.touchPointID).y = eMove.stageY ??35;
         switch (ballgroup.length)
         {//删除已有的线
             case 0 :
                 break;
             case 1 :
                 break;
             case 2 :
                 removeChild(getChildByName(“line1??);
                 break;
             default :
                 for (var m:int =1; m<=ballgroup.length; m++)
                 {
                     removeChild(getChildByName(“line??+ m.toString()));
                 }
         }
         switch (ballgroup.length)
         {//重新画一遍所有的??
             case 0 :
                 break;
             case 1 :
                 break;
             case 2 :
                 var myline1:Sprite = new Sprite();
                 myline1.name = “line1??
                 myline1.graphics.clear();
                 myline1.graphics.lineStyle(4, color, 1);
                 myline1.graphics.moveTo(ballgroup[0].x + ballgroup[0].width/2, ballgroup[0].y + ballgroup[0].height/2);
                 myline1.graphics.lineTo(ballgroup[1].x + ballgroup[1].width/2, ballgroup[1].y + ballgroup[1].height/2);
                 addChild(myline1);
                 break;
             default :
                 for (var n:int =1; n<ballgroup.length; n++)
                 {
                     var myline2:Sprite = new Sprite();
                     myline2.name = “line??+ n.toString();
                     myline2.graphics.clear();
                     myline2.graphics.lineStyle(4,color, 1);
                     myline2.graphics.moveTo(ballgroup[n-1].x + ballgroup[n-1].width/2, ballgroup[n-1].y + ballgroup[n-1].height/2);
                     myline2.graphics.lineTo(ballgroup[n].x + ballgroup[n].width/2, ballgroup[n].y + ballgroup[n].height/2);
                     addChild(myline2);
                 }
                 var myline3:Sprite = new Sprite();
                 myline3.name = “line??+ (ballgroup.length);
                 myline3.graphics.clear();
                 myline3.graphics.lineStyle(4,color, 1);
                 myline3.graphics.moveTo(ballgroup[0].x + ballgroup[0].width/2, ballgroup[0].y + ballgroup[0].height/2);
                 myline3.graphics.lineTo(ballgroup[ballgroup.length-1].x + ballgroup[ballgroup.length-1].width/2, ballgroup[ballgroup.length-1].y + ballgroup[ballgroup.length-1].height/2);
                 addChild(myline3);
         }
         //eEnd.target.stopTouchDrag(eEnd.touchPointID);
         //eEnd.target.removeChildAt(1);
    }
    function onTouchEnd(eEnd:TouchEvent)
    {
         touchtotal = touchtotal ??1;
         mytext2.text = “● You have touched ??+ touchtotal + “points??
         removeChild(getChildByName(“ball??+ eEnd.touchPointID));
         switch (ballgroup.length)
         {
             case 0 :
                 break;
             case 1 :
                 break;
             case 2 :
                 removeChild(getChildByName(“line1??);
                 break;
             default :
                 for (var m:int =1; m<=ballgroup.length; m++)
                 {
                     removeChild(getChildByName(“line??+ m.toString()));
                 }
         }
         touchgrouplength = touchgroup.length;
         for (var j:int=0; j<touchgrouplength; j++)
         {
             if (touchgroup[j] == eEnd.touchPointID)
             {
                 touchgroup.splice(j, 1);
                 ballgroup.splice(j, 1);
                 break;
             }
         }
         switch (ballgroup.length)
         {//重新画一遍所有的??
             case 0 :
                 break;
             case 1 :
                 color = rgb();
                 break;
             case 2 :
                 var myline1:Sprite = new Sprite();
                 myline1.name = “line1??
                 myline1.graphics.clear();
                 myline1.graphics.lineStyle(4, color, 1);
                 myline1.graphics.moveTo(ballgroup[0].x + ballgroup[0].width/2, ballgroup[0].y + ballgroup[0].height/2);
                 myline1.graphics.lineTo(ballgroup[1].x + ballgroup[1].width/2, ballgroup[1].y + ballgroup[1].height/2);
                 addChild(myline1);
                 break;
             default :
                 for (var n:int =1; n<ballgroup.length; n++)
                 {
                     var myline2:Sprite = new Sprite();
                     myline2.name = “line??+ n.toString();
                     myline2.graphics.clear();
                     myline2.graphics.lineStyle(4,color, 1);
                     myline2.graphics.moveTo(ballgroup[n-1].x + ballgroup[n-1].width/2, ballgroup[n-1].y + ballgroup[n-1].height/2);
                     myline2.graphics.lineTo(ballgroup[n].x + ballgroup[n].width/2, ballgroup[n].y + ballgroup[n].height/2);
                     addChild(myline2);
                 }
                 var myline3:Sprite = new Sprite();
                 myline3.name = “line??+ (ballgroup.length);
                 myline3.graphics.clear();
                 myline3.graphics.lineStyle(4, color, 1);
                 myline3.graphics.moveTo(ballgroup[0].x + ballgroup[0].width/2, ballgroup[0].y + ballgroup[0].height/2);
                 myline3.graphics.lineTo(ballgroup[ballgroup.length-1].x + ballgroup[ballgroup.length-1].width/2, ballgroup[ballgroup.length-1].y + ballgroup[ballgroup.length-1].height/2);
                 addChild(myline3);
         }
         //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);
    }

  • 本文相关:
  • ios UIImage 图??居中
  • 在UIImageView中旋转图像代码例??/a>[代码]
    鉴客
  • 使用手势UIGestureRecognizer对图像进行缩放、移动、旋转操??/a>[代码]
    鉴客
  • 使用Objective-C创建UUID的代??/a>[代码]
    鉴客
  • 一个很方便控制视图控件Z轴层次的UIView类别??Category)
  • UIView背景的渐??/a>[代码]
    鉴客
  • iOS设备多点触控和屏幕坏点检测程序代??/a>[代码]
    鉴客
  • tableview滚动到最后一行自动加载数??
  • iPhone toolchain 4.0 的两个配套示例代??/a>[代码]
    鉴客
  • IOS 使用 HTTP POST 上传图片和文本信??/a>[代码]
    红薯
  • 免责声明 - 关于我们 - 联系我们 - 广告联系 - 友情链接 - 帮助中心 - 频道导航
    Copyright © 2015 www.zgxue.com All Rights Reserved