gpt4 book ai didi

actionscript-3 - 如何从手势点捏缩放图片as3

转载 作者:行者123 更新时间:2023-12-04 06:45:05 26 4
gpt4 key购买 nike

我创建了一个图像对象并且能够放大 .但图像只能在图像的中心查看。那么如何放大手势点的图像??

picture.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom);

function onZoom(e:TransformGestureEvent){
picture.scaleX *= (e.scaleX+e.scaleY)/2;
picture.scaleY *= (e.scaleX+e.scaleY)/2;
}

最佳答案

试试这个...

import flash.events.TransformGestureEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import fl.motion.MatrixTransformer;

Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom);
function onZoom(event:TransformGestureEvent):void
{
//trace(e.localX);
var locX:Number=event.localX;
var locY:Number=event.localY;
var stX:Number=event.stageX;
var stY:Number=event.stageY;
var prevScaleX:Number=gambar.scaleX;
var prevScaleY:Number=gambar.scaleY;
var mat:Matrix;
var externalPoint=new Point(stX,stY);
var internalPoint=new Point(locX,locY);

gambar.scaleX *= event.scaleX;
gambar.scaleY *= event.scaleY;

if(event.scaleX > 1 && gambar.scaleX > 6){
gambar.scaleX=prevScaleX;
gambar.scaleY=prevScaleY;
}

if(event.scaleY > 1 && gambar.scaleY > 6){
gambar.scaleX=prevScaleX;
gambar.scaleY=prevScaleY;
}

if(event.scaleX < 1.1 && gambar.scaleX < 1){
gambar.scaleX=prevScaleX;
gambar.scaleY=prevScaleY;
}

if(event.scaleY < 1.1 && gambar.scaleY < 1){
gambar.scaleX=prevScaleX;
gambar.scaleY=prevScaleY;

}
mat=gambar.transform.matrix.clone();
MatrixTransformer.matchInternalPointWithExternal(mat,internalPoint,externalPoint);
gambar.transform.matrix=mat;
}

gambar.addEventListener(MouseEvent.MOUSE_DOWN, f_begin);
gambar.addEventListener(MouseEvent.MOUSE_UP, f_end);
function f_begin(e:MouseEvent):void
{
gambar.startDrag();
}
function f_end(e:MouseEvent):void
{
gambar.stopDrag();
}

顺便说一句,你的照片很可爱..:D

关于actionscript-3 - 如何从手势点捏缩放图片as3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20942298/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com