I use the TransformGestureEvent and StartDrag and StopDrag events, and I'm having some problems.
I will do my best to explain. When I zoom in, my image is scaled and focused during zooming. After I zoom in, I start pulling to the top of my image, when I reach the top I can’t scroll now anymore (everything works as expected so far), but when I goto my image on the axis is no longer reduced above, there is an empty empty place where my image should be.
Here is my code:
mapMC.addEventListener(TransformGestureEvent.GESTURE_ZOOM, zoom);
mapMC.addEventListener(MouseEvent.MOUSE_DOWN, dragStart);
mapMC.addEventListener(MouseEvent.MOUSE_UP, dragEnd);
function zoom (event:TransformGestureEvent):void{
var locX:Number=event.localX;
var locY:Number=event.localY;
var stX:Number=event.stageX;
var stY:Number=event.stageY;
var prevScaleX:Number=mapMC.scaleX;
var prevScaleY:Number=mapMC.scaleY;
var mat:Matrix;
var externalPoint=new Point(stX,stY);
var internalPoint=new Point(locX,locY);
mapMC.scaleX *= event.scaleX;
mapMC.scaleY *= event.scaleY;
if(mapMC.scaleX > 6){
mapMC.scaleX=prevScaleX;
mapMC.scaleY=prevScaleY;
}
if(mapMC.scaleY > 6){
mapMC.scaleX=prevScaleX;
mapMC.scaleY=prevScaleY;
}
if(mapMC.scaleX < 1){
mapMC.scaleX=1;
mapMC.scaleY=1;
}
if(mapMC.scaleY < 1){
mapMC.scaleX=1;
mapMC.scaleY=1;
}
mat=mapMC.transform.matrix.clone();
MatrixTransformer.matchInternalPointWithExternal(mat,internalPoint,externalPoint);
mapMC.transform.matrix=mat;
}
function dragStart(e:MouseEvent):void
{
mapMC.startDrag(false, new Rectangle(0,0,-mapMC.width + stage.stageWidth, -mapMC.height + stage.stageHeight));
}
function dragEnd(e:MouseEvent):void
{
mapMC.stopDrag();
}
, , , , , startDrag .
, , :
mapMC.y = 0;
mapMC.x = 0;
, ,
https://drive.google.com/open?id=0B-p_9V3gzZZTcXpQZzI0RU9ZY0k