Copy link to clipboard
Copied
Hi! I've got a problem with this code, because i need to zoom out for the original size. Please HELP ME in it! thanks
import flash.events.MouseEvent;
stage.addEventListener(MouseEvent.MOUSE_WHEEL, Zoom);
function Zoom(e:MouseEvent):void
{
var mod:Number = 20;
kep2.scaleX += e.delta / mod;
kep2.scaleY += e.delta / mod;
kep2.x = ((2 * mouseX) - (2 * (e.localX * kep2.scaleX))) / 2;
kep2.y = ((2 * mouseY) - (2 * (e.localY * kep2.scaleY))) / 2;
}
import flash.events.MouseEvent;
this.addEventListener(MouseEvent.MOUSE_DOWN, startDragging, true);
this.addEventListener(MouseEvent.MOUSE_UP, stopDragging, true);
function startDragging(e:MouseEvent) {
kep2.startDrag();
}
function stopDragging(e:MouseEvent) {
kep2.stopDrag();
}
use an if-statement to check if scaling is too small
...
import flash.events.MouseEvent;
stage.addEventListener(MouseEvent.MOUSE_WHEEL, Zoom);
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.x = ((2 * mouseX) - (2 * (e.localX * kep2.scaleX))) / 2;
kep2.y = ((2 * mouseY) - (2 * (e.localY * kep2.scaleY))) / 2;
}
import flash.events.MouseEvent;
this.addEve
Copy link to clipboard
Copied
use an if-statement to check if scaling is too small
import flash.events.MouseEvent;
stage.addEventListener(MouseEvent.MOUSE_WHEEL, Zoom);
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.x = ((2 * mouseX) - (2 * (e.localX * kep2.scaleX))) / 2;
kep2.y = ((2 * mouseY) - (2 * (e.localY * kep2.scaleY))) / 2;
}
import flash.events.MouseEvent;
this.addEventListener(MouseEvent.MOUSE_DOWN, startDragging, true);
this.addEventListener(MouseEvent.MOUSE_UP, stopDragging, true);
function startDragging(e:MouseEvent) {
kep2.startDrag();
}
function stopDragging(e:MouseEvent) {
kep2.stopDrag();
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now