I have checked some previous questions like this and another, but none address the issue I'm having. I have a zoom function:
protected function onZoom(e:TransformGestureEvent, img:Image):void
{
DynamicRegistration.scale(img, new Point(e.localX, e.localY), img.scaleX*e.scaleX, img.scaleY*e.scaleX);
}
and the zooming works (and well!), but I'd like to limit the scaling to, say 2.5x and .8x. So my first thought was to try this:
protected function onZoom(e:TransformGestureEvent, img:Image):void
{
while(img.scaleX <= 2.5 && img.scaleX >= .8)
DynamicRegistration.scale(img, new Point(e.localX, e.localY), img.scaleX*e.scaleX, img.scaleY*e.scaleX);
}
But this zoomed to the max limit without any pinch-to-zoom like interaction, where I assume the scale was just above 2.5x and it will not respond to zooming.
My next try was:
protected function onZoom(e:TransformGestureEvent, img:Image):void
{
while(img.scaleX <= 2.5 && img.scaleX >= .8)
{
DynamicRegistration.scale(img, new Point(e.localX, e.localY), img.scaleX*e.scaleX, img.scaleY*e.scaleX);
if(img.scaleX > 2.5)
{
img.scaleX = 2.5;
img.scaleY = 2.5;
}
else if(img.scaleX < .8)
{
img.scaleX = .8;
img.scaleY = .8;
}
}
}
to try to reset the size to within the limits if they were exceeded, but this was mot only unsuccessful, but the image does nothing, and the app locks up and results in a force close.
Does anyone know how this could be accomplished? I like this zoom method because of its simplicity, but can it be used while instantiating bounds on the scaling?