Symbol 3 MovieClip Frame 1
_visible = false;
Symbol 5 MovieClip [SHURIKEN255_CAMERA] Frame 1
function convertToParent(clip, point) {
var _local1 = clip.transform.matrix;
var _local5 = (clip._x + (point.x * _local1.a)) + (point.y * _local1.c);
var _local4 = (clip._y + (point.x * _local1.b)) + (point.y * _local1.d);
point.x = _local5;
point.y = _local4;
}
function convertFromParent(clip, point) {
var _local1 = clip.transform.matrix;
var _local4 = point.x;
var _local3 = point.y;
var _local7 = (((clip._x + (((clip._y - _local3) / (-_local1.d)) * _local1.c)) - _local4) / (-_local1.a)) / (1 - ((_local1.b * _local1.c) / (_local1.d * _local1.a)));
var _local6 = (((clip._y + (((clip._x - _local4) / (-_local1.a)) * _local1.b)) - _local3) / (-_local1.d)) / (1 - ((_local1.c * _local1.b) / (_local1.a * _local1.d)));
point.x = _local7;
point.y = _local6;
}
function cameraLogic() {
resetParentsPosition();
moveViewframe();
attachParentToViewframe();
shakeLogic();
}
function shakeLogic() {
inverted = !inverted;
var _local2 = _parent.shuriken255_shake_multiplier;
if (_local2 == undefined) {
_local2 = defaultShakeMultiplier;
}
shakeX = shakeX * _local2;
shakeY = shakeY * _local2;
}
function moveViewframe() {
viewfinder._x = 0;
viewfinder._y = 0;
viewfinder._xscale = 100;
viewfinder._yscale = 100;
viewfinder._rotation = -this._rotation;
var _local11 = _x;
var _local9 = _y;
var _local12 = _xscale;
var _local10 = _yscale;
var _local13 = _rotation;
var _local5 = _local13 - prevR;
if (_local5 < -180) {
_local5 = _local5 + 360;
}
if (_local5 > 180) {
_local5 = _local5 - 360;
}
var _local6 = prevR + (_local5 * binding);
var _local3 = prevX + ((_local11 - prevX) * binding);
var _local4 = prevY + ((_local9 - prevY) * binding);
var _local8 = prevW + ((_local12 - prevW) * binding);
var _local7 = prevH + ((_local10 - prevH) * binding);
prevX = _local3;
prevY = _local4;
prevW = _local8;
prevH = _local7;
prevR = _local6;
if (inverted && (shakeX != undefined)) {
_local3 = _local3 - shakeX;
_local4 = _local4 - shakeY;
} else {
_local3 = _local3 + shakeX;
_local4 = _local4 + shakeY;
}
if ((_local3 == 0) && (_local4 == 0)) {
_local3 = 0.5;
}
if (lastTrackingFrame != -2) {
if (_parent._currentframe > lastTrackingFrame) {
lastTrackingFrame = _parent._currentframe;
trace((((((((_local3 + " ") + _local4) + " ") + ((_local8 * oW) / 100)) + " ") + ((_local7 * oH) / 100)) + " ") + _local6);
} else {
lastTrackingFrame = -2;
trace("Done! Copy everything above into \"camera_tracking.txt\".");
}
}
point.x = _local3;
point.y = _local4;
convertFromParent(this, point);
viewfinder._x = point.x;
viewfinder._y = point.y;
viewfinder._xscale = ((_local8 / 100) / (_xscale / 100)) * 100;
viewfinder._yscale = ((_local7 / 100) / (_yscale / 100)) * 100;
viewfinder._rotation = _local6 - _rotation;
}
function attachParentToViewframe() {
point.x = (-oW) / 2;
point.y = (-oH) / 2;
convertToParent(viewfinder, point);
convertToParent(this, point);
var _local17 = point.x;
var _local16 = point.y;
var _local21 = 0;
var _local20 = 0;
point.x = oW / 2;
point.y = (-oH) / 2;
convertToParent(viewfinder, point);
convertToParent(this, point);
var _local4 = point.x;
var _local5 = point.y;
var _local15 = sW;
var _local13 = 0;
point.x = (-oW) / 2;
point.y = oH / 2;
convertToParent(viewfinder, point);
convertToParent(this, point);
var _local6 = point.x;
var _local3 = point.y;
var _local14 = 0;
var _local12 = sH;
var _local11 = _parent.transform.matrix;
var _local18 = (_local6 * _local5) / (_local4 * _local3);
var _local8 = _local4 * (1 - _local18);
var _local7 = _local3 * (1 - _local18);
var _local19 = (((_local17 / _local8) + (_local16 / _local7)) - ((_local5 * _local17) / (_local3 * _local8))) - ((_local6 * _local16) / (_local4 * _local7));
var _local10 = ((_local21 - (((_local15 - ((_local14 / _local3) * _local5)) / _local8) * _local17)) - (((_local14 - ((_local15 / _local4) * _local6)) / _local7) * _local16)) / (1 - _local19);
var _local9 = ((_local20 - (((_local13 - ((_local12 / _local3) * _local5)) / _local8) * _local17)) - (((_local12 - ((_local13 / _local4) * _local6)) / _local7) * _local16)) / (1 - _local19);
_local11.a = ((_local15 - _local10) - (((_local14 - _local10) / _local3) * _local5)) / _local8;
_local11.b = ((_local13 - _local9) - (((_local12 - _local9) / _local3) * _local5)) / _local8;
_local11.c = ((_local14 - _local10) - (((_local15 - _local10) / _local4) * _local6)) / _local7;
_local11.d = ((_local12 - _local9) - (((_local13 - _local9) / _local4) * _local6)) / _local7;
_parent.transform.matrix = _local11;
_parent._x = _local10;
_parent._y = _local9;
}
function resetParentsPosition() {
_parent._x = 0;
_parent._y = 0;
var _local2 = _parent.transform.matrix;
_local2.a = 1;
_local2.b = 0;
_local2.c = 0;
_local2.d = 1;
_parent.transform.matrix = _local2;
}
function addParallaxSymbol(parallax) {
if (parallaxSymbols == null) {
parallaxSymbols = new Array();
}
parallaxSymbols.push(parallax);
}
function removeParallaxSymbol(parallax) {
var _local1 = 0;
while (_local1 < parallaxSymbols.length) {
if (parallaxSymbols[_local1] == parallax) {
parallaxSymbols.splice(_local1, 1);
return(undefined);
}
_local1++;
}
}
function moveParallaxes() {
if (parallaxSymbols == null) {
return(undefined);
}
var _local2 = getViewfinderLocation();
var _local1 = 0;
while (_local1 < parallaxSymbols.length) {
if (parallaxSymbols[_local1] == null) {
parallaxSymbols.splice(_local1, 1);
_local1--;
} else {
parallaxSymbols[_local1].putParallax(_local2);
}
_local1++;
}
}
function getViewfinderLocation() {
var _local2 = new Object();
var _local3 = new Object();
_local2.x = 0;
_local2.y = 0;
convertToParent(viewfinder, _local2);
convertToParent(this, _local2);
_local3.x = ((_local2.x * 2) / sw) - 1;
_local3.y = ((_local2.y * 2) / sh) - 1;
_local2.x = (-oW) / 2;
_local2.y = (-oH) / 2;
convertToParent(viewfinder, _local2);
convertToParent(this, _local2);
var _local6 = _local2.x;
var _local4 = _local2.y;
_local2.x = oW / 2;
_local2.y = (-oH) / 2;
convertToParent(viewfinder, _local2);
convertToParent(this, _local2);
var _local13 = _local2.x;
var _local11 = _local2.y;
_local2.x = (-oW) / 2;
_local2.y = oH / 2;
convertToParent(viewfinder, _local2);
convertToParent(this, _local2);
var _local12 = _local2.x;
var _local10 = _local2.y;
var _local9 = _local13 - _local6;
var _local7 = _local11 - _local4;
var _local8 = _local12 - _local6;
var _local5 = _local10 - _local4;
_local3.pw = Math.sqrt((_local9 * _local9) + (_local7 * _local7));
_local3.ph = Math.sqrt((_local8 * _local8) + (_local5 * _local5));
_local3.z = 1 - (_local3.pw / sw);
return(_local3);
}
function activateShakeController() {
var _local2 = searchForMovieClip(_parent, "isAShakeControllerByShuriken255", 0);
if (_local2 != null) {
_local2.searchForShake();
}
}
function activateBindingController() {
var _local2 = searchForMovieClip(_parent, "isABindingByShuriken255", 0);
if (_local2 != null) {
_local2.searchForCamera();
_local2.onEnterFrame();
}
}
function searchForMovieClip(where, identifier, level) {
if (level > 0) {
level--;
for (var _local6 in where) {
if (where[_local6] instanceof MovieClip) {
var _local3 = searchForMovieClip(where[_local6], identifier, level);
if (_local3 != null) {
return(_local3);
}
}
}
} else {
for (var _local6 in where) {
if (where[_local6] instanceof MovieClip) {
var _local2 = where[_local6];
if (_local2[identifier]) {
return(_local2);
}
}
}
}
return(null);
}
function searchForMovieClips(where, identifier, level) {
var _local3 = new Array();
if (level > 0) {
level--;
for (var _local7 in where) {
if (where[_local7] instanceof MovieClip) {
var _local4 = searchForMovieClips(where[_local7], identifier, level);
_local3 = _local3.concat(_local4);
}
}
} else {
for (var _local7 in where) {
if (where[_local7] instanceof MovieClip) {
var _local2 = where[_local7];
if (_local2[identifier]) {
_local3.push(_local2);
}
}
}
}
return(_local3);
}
function initializeParallaxes() {
var _local3 = searchForMovieClips(_parent, "isParallaxByShuriken255", 1);
var _local2 = 0;
while (_local2 < _local3.length) {
_local3[_local2].initialized = _local3[_local2].tryToInit();
_local2++;
}
}
onEnterFrame = function () {
_root.filters = this.filters;
cameraLogic();
moveParallaxes();
};
onUnload = function () {
_root.filters = new Array();
resetParentsPosition();
moveParallaxes();
};
var binding = 1;
var isACameraByShuriken255 = true;
var bounds = viewfinder.getBounds(viewfinder);
var oW = (bounds.xMax - bounds.xMin);
var oH = (bounds.yMax - bounds.yMin);
var sW = Stage.width;
var sH = Stage.height;
var swR = (Stage.width / oW);
var shR = (Stage.height / oH);
var point = new Object();
var prevX = _x;
var prevY = _y;
var prevW = _xscale;
var prevH = _yscale;
var prevR = _rotation;
var defaultShakeMultiplier = 0.75;
var inverted = false;
var shakeX = 0;
var shakeY = 0;
var lastTrackingFrame = -2;
var parallaxSymbols;
var sw = Stage.width;
var sh = Stage.height;
initializeParallaxes();
activateShakeController();
activateBindingController();
onEnterFrame();