Hi everyone!
Just recently I used this sniper zoom program someone published on another forum as part of my working prototype for my final year project. In my report I have to document all the code researched so far for my project. I am just wondering if anyone can give me any comments or explanation on any part of the code below, as I’m quite inept at understanding it and you guys are real experts. I have attached a file which is related to the code below which allows the binoculors to zoom in etc. Thanks for any help you can give me!!
onClipEvent (load) {
this.startDrag(true);
lastPoint = new Object();
thisPoint = new Object();
lastPoint.x = 0;
lastPoint.y = 0;
//
zoomScale = new Array(50, 100, 150);
zoomLevel = 0;
//
c = new Color(_parent.scene);
t = new Object();
n = new Object();
scopeOn = {ra:'100', rb:'-100', ga:'100', gb:'-100', ba:'100', bb:'-100', aa:'100', ab:'100'};
scopeOff = {ra:'100', rb:'0', ga:'100', gb:'0', ba:'100', bb:'0', aa:'100', ab:'100'};
lastTransform = true;
//
//
function zoom () {
if (Key.isDown(Key.SHIFT)) {
if (zoomLevel < (zoomScale.length - 1))
zoomLevel++;
else
zoomLevel=0;
scene._x = scene._y = lastPoint.x = lastPoint.y = 0;
}
if (Key.isDown(Key.CONTROL)) {
_xscale = _yscale = 200;
scene._xscale = scene._yscale = zoomScale[zoomLevel];
_quality = "LOW";
if (lastTransform == true) {
c.setTransform(scopeOn);
}
lastTransform = false;
scene._visible = true;
thisPoint.x = _root._xmouse;
thisPoint.y = _root._ymouse;
_root.scene.globalToLocal(thisPoint);
x = (thisPoint.x-lastPoint.x)/(100 / zoomScale[zoomLevel]);
y = (thisPoint.y-lastPoint.y)/(100 / zoomScale[zoomLevel]);
scene._x = scene._x-x;
scene._y = scene._y-y;
lastPoint.x = thisPoint.x;
lastPoint.y = thisPoint.y;
} else {
_xscale = _yscale = 100;
_quality = "HIGH";
scene._visible = false;
if (lastTransform == false) {
c.setTransform(scopeOff);
}
lastTransform = true;
}
}
}
//
onClipEvent (mouseMove) {
zoom();
}
//
onClipEvent (keyDown) {
zoom();
}
//
onClipEvent (keyUp) {
zoom();
}
//
onClipEvent (mouseDown) {
_root.attachMovie("bullet", "bullet", 1);
_root.bullet._x = _root._xmouse;
_root.bullet._y = _root._ymouse;
if (Key.isDown(Key.SHIFT)) {
_root.bullet._xscale = _root.bullet._yscale=300;
}
}