Copy link to clipboard
Copied
Hello! I've got a problem with the fluency of the zoom. When I want to zoom the image is bouncing. Please help me!
import flash.events.MouseEvent;
stage.addEventListener(MouseEvent.MOUSE_WHEEL, Zoom);
function Zoom(e:MouseEvent):void
{
var mod:Number = 20;
img_mc.scaleX += e.delta / mod;
img_mc.scaleY += e.delta / mod;
if( img_mc.scaleX<1){
img_mc.scaleX= img_mc.scaleY=1;
}
img_mc.x = ((mouseX) - (((e.stageX - 683) * img_mc.scaleX)));
img_mc.y = ((mouseY) - (((e.stageY - 280.5) * img_mc.scaleY)));
}
Thanks
Copy link to clipboard
Copied
I would suggest two things - first, if this is an image you're zooming, that smoothing is enabled in it's properties or you're setting it by code. Second, you have 280.5 in your y setting. Things cannot be on half pixels even though Flash, as a vector tool, allows it.Flash shouldn't allow it. Not using whole integers for positioning can make text look ugly, images appear aliased, etc...
Copy link to clipboard
Copied
Where can i enabled the smoothing? What can i use instead of these numbers?
Thanks
Copy link to clipboard
Copied
You enable smoothing either in the images properties, or by code if you're loading by code. Use integers instead of floats is all...
Copy link to clipboard
Copied
Other question: If i use this zoom code, but i want to zoom to the position of the mouse?
function Zoom(e:MouseEvent):void
{
var mod:Number = 20;
kep2.scaleX += e.delta / mod;
kep2.scaleY += e.delta / mod;
if(kep2.scaleX<1){
kep2.scaleX=kep2.scaleY=1;
}
kep2.scaleX *= Math.max(scaleY,scaleX);
kep2.scaleY *= Math.max(scaleX,scaleY);
thanks