我想在我的Android应用程序中模拟缩放(放大镜)一些文字信息
使用这些脚本启用滑动和缩放手势到我的文本(我放入带有实例名称的movieclip: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;
}
现在我可以使用缩放和滑动来读取更大尺寸的文本(更容易阅读),但现在有两个问题:
2.滑动功能将持续到文本退出舞台并消失!!如何在textzoom movieclip完全退出舞台之前停止滑动功能?因此,用户可以检测并查看文本的一角并将其向后滑动