Skip to main content
Arioman
Inspiring
May 14, 2014
Question

limit Area of zoom and swipe in Gesture script

  • May 14, 2014
  • 0 replies
  • 502 views

hi , i want to simulate zoom ( magnifier ) some text info in my android app

use these script to enable swipe and Zoom Gesture to my text ( that i put in movieclip with instance name : textzoom)

import flash.ui.Multitouch;

import flash.ui.MultitouchInputMode;

import flash.events.TransformGestureEvent;

import flash.events.GestureEvent;

var origX:Number;

var origY:Number;

Multitouch.inputMode = MultitouchInputMode.GESTURE;

origX = textzoom.x;

origY = textzoom.y;

textzoom.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom);

function onZoom(e:TransformGestureEvent):void {

   

    if (textzoom.scaleX > 0.5 && textzoom.scaleX < 3) {

       

        textzoom.scaleX *= e.scaleX;

        textzoom.scaleY = textzoom.scaleX;

       

    } else if (textzoom.scaleX < 0.5) {

        textzoom.scaleX = 0.51;

        textzoom.scaleY = textzoom.scaleX;

       

    } else if (textzoom.scaleX > 3) {

        textzoom.scaleX =2.99;

        textzoom.scaleY = textzoom.scaleX;

    }

    //trace (e.scaleX );

}

stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE , onSwipe);

function onSwipe (e:TransformGestureEvent):void{

   

   

if (e.offsetX == 1) {

//User swiped towards right

textzoom.x += 100;

}

if (e.offsetX == -1) {

//User swiped towards left

textzoom.x -= 100;

}

if (e.offsetY == 1) {

//User swiped towards bottom

textzoom.y += 100;

}

if (e.offsetY == -1) {

//User swiped towards top

textzoom.y -= 100;

}

}

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener(GestureEvent.GESTURE_TWO_FINGER_TAP, twoFingerTapHandler);

function twoFingerTapHandler(event:GestureEvent):void

{

        textzoom.scaleX =1;

        textzoom.scaleY = textzoom.scaleX;

        textzoom.x = origX;

        textzoom.y = origY;

       

    }

now i can use zoom and swipe for read text in bigger size ( make easier to read ) , but now there is two problem :

1. when i zoom the text grows in stage and will cover all my screen and other part , and i don't want this , i just want the zoom function effect on the textzoom movieclip area .

2.the swipe function will continue till the text goes out of stage and disappeared !! how can i stop swipe function before textzoom movieclip goes out of stage completely ? so user can detect and see the corner of text and swipe them back

I upload two image to explain it better cause my english is not very good.

i really need to solve this , please help me , thanks

This topic has been closed for replies.