Multi Touch
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Multi Touch

  1. #1
    Is the best Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    395

    Multi Touch

    Hi, i have a grid array of buttons, but when i add multitouch zoom code to it which is found at the end of the script, only the last button in the array zooms in and out, any idea how to get it all into some sort of container in as3 and just be able to zoom the whole thing. Thanks

    PHP Code:
    import flash.events.MouseEvent

    var 
    rows:int 40
    var 
    cols:int 50

    for (var 
    py:int 0py <rowspy++) 

        for (var 
    px:int 0px <colspx++) 
        { 
            var 
    grid:Grid = new Grid(); 
            
    grid.200 grid.width px
            
    grid.50 grid.height py
            
    grid.addEventListener(MouseEvent.ROLL_OVER,doFunction); 
            
    addChild(grid); 
        } 


    function 
    doFunction(e:MouseEvent):void 

        
    trace(e.currentTarget); 
        
    trace(MovieClip(root).color_black.currentFrame); 
        if (
    MovieClip(root).color_black.currentFrame == 2
        { 
            
    e.currentTarget.gotoAndStop(1); 
        } 
        if (
    MovieClip(root).color_grey.currentFrame == 2
        { 
            
    e.currentTarget.gotoAndStop(2); 
        }
        if (
    MovieClip(root).color_white.currentFrame == 2
        { 
            
    e.currentTarget.gotoAndStop(3); 
        }
        if (
    MovieClip(root).color_yellow.currentFrame == 2
        { 
            
    e.currentTarget.gotoAndStop(4); 
        }
        if (
    MovieClip(root).color_green.currentFrame == 2
        { 
            
    e.currentTarget.gotoAndStop(5); 
        }
        if (
    MovieClip(root).color_blue.currentFrame == 2
        { 
            
    e.currentTarget.gotoAndStop(6); 
        }
        if (
    MovieClip(root).color_brown.currentFrame == 2
        { 
            
    e.currentTarget.gotoAndStop(7); 
        }
        if (
    MovieClip(root).color_red.currentFrame == 2
        { 
            
    e.currentTarget.gotoAndStop(8); 
    }
    }


    color_black.addEventListener(MouseEvent.CLICKgo);
    function 
    go(event:MouseEvent): void {
    color_black.gotoAndStop(2);
    color_grey.gotoAndStop(1);
    color_white.gotoAndStop(1);
    color_yellow.gotoAndStop(1);
    color_green.gotoAndStop(1);
    color_blue.gotoAndStop(1);
    color_brown.gotoAndStop(1);
    color_red.gotoAndStop(1);

    }

    color_grey.addEventListener(MouseEvent.CLICKgo2);
    function 
    go2(event:MouseEvent): void {
    color_black.gotoAndStop(1);
    color_grey.gotoAndStop(2);
    color_white.gotoAndStop(1);
    color_yellow.gotoAndStop(1);
    color_green.gotoAndStop(1);
    color_blue.gotoAndStop(1);
    color_brown.gotoAndStop(1);
    color_red.gotoAndStop(1);
    }

    color_white.addEventListener(MouseEvent.CLICKgo3);
    function 
    go3(event:MouseEvent): void {
    color_black.gotoAndStop(1);
    color_grey.gotoAndStop(1);
    color_white.gotoAndStop(2);
    color_yellow.gotoAndStop(1);
    color_green.gotoAndStop(1);
    color_blue.gotoAndStop(1);
    color_brown.gotoAndStop(1);
    color_red.gotoAndStop(1);
    }


    color_yellow.addEventListener(MouseEvent.CLICKgo4);
    function 
    go4(event:MouseEvent): void {
    color_black.gotoAndStop(1);
    color_grey.gotoAndStop(1);
    color_white.gotoAndStop(1);
    color_yellow.gotoAndStop(2);
    color_green.gotoAndStop(1);
    color_blue.gotoAndStop(1);
    color_brown.gotoAndStop(1);
    color_red.gotoAndStop(1);
    }

    color_green.addEventListener(MouseEvent.CLICKgo5);
    function 
    go5(event:MouseEvent): void {
    color_black.gotoAndStop(1);
    color_grey.gotoAndStop(1);
    color_white.gotoAndStop(1);
    color_yellow.gotoAndStop(1);
    color_green.gotoAndStop(2);
    color_blue.gotoAndStop(1);
    color_brown.gotoAndStop(1);
    color_red.gotoAndStop(1);
    }

    color_blue.addEventListener(MouseEvent.CLICKgo6);
    function 
    go6(event:MouseEvent): void {
    color_black.gotoAndStop(1);
    color_grey.gotoAndStop(1);
    color_white.gotoAndStop(1);
    color_yellow.gotoAndStop(1);
    color_green.gotoAndStop(1);
    color_blue.gotoAndStop(2);
    color_brown.gotoAndStop(1);
    color_red.gotoAndStop(1);;
    }

    color_brown.addEventListener(MouseEvent.CLICKgo7);
    function 
    go7(event:MouseEvent): void {
    color_black.gotoAndStop(1);
    color_grey.gotoAndStop(1);
    color_white.gotoAndStop(1);
    color_yellow.gotoAndStop(1);
    color_green.gotoAndStop(1);
    color_blue.gotoAndStop(1);
    color_brown.gotoAndStop(2);
    color_red.gotoAndStop(1);
    }

    color_red.addEventListener(MouseEvent.CLICKgo8);
    function 
    go8(event:MouseEvent): void {
    color_black.gotoAndStop(1);
    color_grey.gotoAndStop(1);
    color_white.gotoAndStop(1);
    color_yellow.gotoAndStop(1);
    color_green.gotoAndStop(1);
    color_blue.gotoAndStop(1);
    color_brown.gotoAndStop(1);
    color_red.gotoAndStop(2);
    }



    Multitouch.inputMode MultitouchInputMode.GESTURE;

    stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM onZoom); 
    function 
    onZoom (e:TransformGestureEvent):void{
    grid.scaleX *= (e.scaleX+e.scaleY)/2
    grid.scaleY *= (e.scaleX+e.scaleY)/2

    https://www.paypal.com/cgi-bin/websc...if%3aNonHosted <--- Please donate if I solved your problem

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,059
    Hi Alloy,

    You can shorten that lot down using arrays and loops, try this
    PHP Code:
    import flash.events.MouseEvent;

    var 
    rows:int 40;
    var 
    i:int;
    var 
    colorArray:Array = new Array(color_black,color_grey,color_white,color_yellow,color_green,color_blue,color_brown,color_red);

    for (
    0colorArray.lengthi++)
    {
        
    colorArray[i].addEventListener(MouseEvent.CLICKgo);
    }

    for (
    02000i++)
    {
        var 
    grid:Grid = new Grid();
        
    grid.200 Math.floor(rows) * (grid.width 1);
        
    grid.50 Math.floor(rows) * (grid.height 1);
        
    grid.name "Grid Member:" + (1);
        
    grid.addEventListener(MouseEvent.ROLL_OVER,doFunction);
        
    addChild(grid);
    }

    function 
    doFunction(event:MouseEvent):void
    {
        
    trace(event.currentTarget.name);
        for (
    0colorArray.lengthi++)
        {
            if (
    colorArray[i].currentFrame == 2)
            {
                
    colorArray[i].gotoAndStop(1);
            }
        }
    }

    function 
    go(event:MouseEvent):void
    {
        for (
    0colorArray.lengthi++)
        {
            
    colorArray[i].gotoAndStop(1);
        }
        
    event.currentTarget.gotoAndStop(2);

    I havent tried messing with the mulitouch thing yet, as I don't use it.

    Im not even sure how you test it as I dont have a touch screen

    just ssaw the container part too
    PHP Code:
    import flash.events.MouseEvent;
    import flash.display.MovieClip;

    var 
    rows:int 40;
    var 
    i:int;

    var 
    colorArray:Array = new Array(color_black,color_grey,color_white,color_yellow,color_green,color_blue,color_brown,color_red);

    var 
    container:MovieClip = new MovieClip();
    addChild(container);
    with (container)
    {
        
    200;
        
    50;
    }

    for (
    0colorArray.lengthi++)
    {
        
    colorArray[i].addEventListener(MouseEvent.CLICKgo);
    }

    for (
    02000i++)
    {
        var 
    grid:Grid = new Grid();
        
    grid.Math.floor(rows) * (grid.width 1);
        
    grid.Math.floor(rows) * (grid.height 1);
        
    grid.name "Grid Member:" + (1);
        
    grid.addEventListener(MouseEvent.ROLL_OVER,doFunction);
        
    container.addChild(grid);
    }

    function 
    doFunction(event:MouseEvent):void
    {
        
    trace(event.currentTarget.name);
        for (
    0colorArray.lengthi++)
        {
            if (
    colorArray[i].currentFrame == 2)
            {
                
    colorArray[i].gotoAndStop(1);
            }
        }
    }

    function 
    go(event:MouseEvent):void
    {
        for (
    0colorArray.lengthi++)
        {
            
    colorArray[i].gotoAndStop(1);
        }
        
    event.currentTarget.gotoAndStop(2);

    Last edited by fruitbeard; 08-28-2014 at 11:50 AM.

  3. #3
    Is the best Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    395
    you use the adobe air phone tools, for example you set 1 point for zoom and than u seperate or closen the next point and it simulates it, i use that and my android to test it thanks for the shortening code http://i.imgur.com/pLAOgIG.png
    https://www.paypal.com/cgi-bin/websc...if%3aNonHosted <--- Please donate if I solved your problem

  4. #4
    Is the best Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    395
    i can no longer change states in my array but i got the zoom working thanks to your container did you eliminate the ROLL_OVER stuff
    Last edited by Alloy Bacon; 08-28-2014 at 12:37 PM.
    https://www.paypal.com/cgi-bin/websc...if%3aNonHosted <--- Please donate if I solved your problem

  5. #5
    Is the best Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    395
    I fixed it, Thanks I went back to my old long code but kept the container
    https://www.paypal.com/cgi-bin/websc...if%3aNonHosted <--- Please donate if I solved your problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com