Frame 1
fscommand ("fullscreen", "true");
function playSound() {
var _local2 = new Sound(this);
_local2.attachSound("sound");
_local2.start();
}
var last_sound = 0;
MovieClip.prototype.drawArc = function (x, y, radius, arc, startAngle, yRadius) {
if (arguments.length < 5) {
return(undefined);
}
if (yRadius == undefined) {
yRadius = radius;
}
var _local17;
var _local4;
var _local3;
var _local6;
var _local15;
var _local11;
var _local9;
var _local10;
var _local8;
var _local14;
var _local13;
if (Math.abs(arc) > 360) {
arc = 360;
}
_local15 = Math.ceil(Math.abs(arc) / 45);
_local17 = arc / _local15;
_local4 = (-(_local17 / 180)) * Math.PI;
_local3 = (-(startAngle / 180)) * Math.PI;
_local11 = x - (Math.cos(_local3) * radius);
_local9 = y - (Math.sin(_local3) * yRadius);
if (_local15 > 0) {
var _local5 = 0;
while (_local5 < _local15) {
_local3 = _local3 + _local4;
_local6 = _local3 - (_local4 / 2);
_local10 = _local11 + (Math.cos(_local3) * radius);
_local8 = _local9 + (Math.sin(_local3) * yRadius);
_local14 = _local11 + (Math.cos(_local6) * (radius / Math.cos(_local4 / 2)));
_local13 = _local9 + (Math.sin(_local6) * (yRadius / Math.cos(_local4 / 2)));
this.curveTo(_local14, _local13, _local10, _local8);
_local5++;
}
}
return({x:_local10, y:_local8});
};
MovieClip.prototype.drawOval = function (x, y, radius, yRadius) {
if (arguments.length < 3) {
return(undefined);
}
var _local6;
var _local16;
var _local15;
var _local3;
var _local5;
var _local10;
var _local9;
var _local8;
var _local7;
if (yRadius == undefined) {
yRadius = radius;
}
_local6 = (Math.PI/4);
_local16 = radius / Math.cos(_local6 / 2);
_local15 = yRadius / Math.cos(_local6 / 2);
_local3 = 0;
this.moveTo(x + radius, y);
var _local4 = 0;
while (_local4 < 8) {
_local3 = _local3 + _local6;
_local5 = _local3 - (_local6 / 2);
_local8 = x + (Math.cos(_local5) * _local16);
_local7 = y + (Math.sin(_local5) * _local15);
_local10 = x + (Math.cos(_local3) * radius);
_local9 = y + (Math.sin(_local3) * yRadius);
this.curveTo(_local8, _local7, _local10, _local9);
_local4++;
}
};
MovieClip.prototype.dashTo = function (startx, starty, endx, endy, len, gap) {
if (arguments.length < 6) {
return(false);
}
var _local10;
var _local8;
var _local7;
var _local9;
var _local4;
var _local3;
_local10 = len + gap;
_local8 = endx - startx;
_local7 = endy - starty;
delta = Math.sqrt((_local8 * _local8) + (_local7 * _local7));
_local9 = Math.floor(Math.abs(delta / _local10));
radians = Math.atan2(_local7, _local8);
_local4 = startx;
_local3 = starty;
_local8 = Math.cos(radians) * _local10;
_local7 = Math.sin(radians) * _local10;
var _local5 = 0;
while (_local5 < _local9) {
this.moveTo(_local4, _local3);
this.lineTo(_local4 + (Math.cos(radians) * len), _local3 + (Math.sin(radians) * len));
_local4 = _local4 + _local8;
_local3 = _local3 + _local7;
_local5++;
}
this.moveTo(_local4, _local3);
delta = Math.sqrt(((endx - _local4) * (endx - _local4)) + ((endy - _local3) * (endy - _local3)));
if (delta > len) {
this.lineTo(_local4 + (Math.cos(radians) * len), _local3 + (Math.sin(radians) * len));
} else if (delta > 0) {
this.lineTo(_local4 + (Math.cos(radians) * delta), _local3 + (Math.sin(radians) * delta));
}
this.moveTo(endx, endy);
};
function showRoll() {
trail = Math.min(trail, roll_length + (5 * sheet_length));
trail = Math.max(trail_min, trail);
calcRemainder();
if (trail_prev != trail) {
radius_cur = trailToRadius(trail, roll_length, radius_min, thickness);
drawRoll(mc_roll, radius_cur, trail);
if (cookie_enabled) {
so.data.trail = trail;
}
}
trail_prev = trail;
}
function calcRemainder() {
remainder = Math.round((roll_length + (1 * sheet_length)) - trail);
}
var ml = {};
ml.container = this;
Mouse.addListener(ml);
ml.onMouseWheel = function (d) {
var _local2 = (-d) * this.container.scrollspeed;
if (zwiep_down and (_local2 > 10)) {
this.container.current_speed = _local2;
} else if (zwiep_up and (_local2 < -10)) {
this.container.current_speed = _local2;
} else {
this.container.trail = this.container.trail + _local2;
this.container.showRoll();
this.container.current_speed = 0;
}
};
this.onKeyDown = function () {
if (Key.isDown(16)) {
if (Key.isDown(40)) {
if (this.onEnterFrame == null) {
current_speed = autospeed;
} else {
current_speed = 0;
}
} else if (Key.isDown(38)) {
if (this.onEnterFrame == null) {
current_speed = -autospeed;
} else {
current_speed = 0;
}
}
if (Key.isDown(34)) {
var _local2 = 1.01 * sheet_length;
} else if (Key.isDown(33)) {
var _local2 = -1.01 * sheet_length;
} else if (Key.isDown(36)) {
var _local2 = trail_min - trail;
} else if (Key.isDown(35)) {
var _local2 = trail_max - trail;
}
} else if (Key.isDown(40)) {
var _local2 = keyspeed;
} else if (Key.isDown(38)) {
var _local2 = -keyspeed;
}
if (_local2 != undefined) {
current_speed = 0;
trail = trail + _local2;
showRoll();
}
};
Key.addListener(this);
this.onMouseDown = function () {
if (remainder < (perimeter_min / 2)) {
return(undefined);
}
current_speed = 0;
startpos = [_xmouse, _ymouse];
this.onMouseMove = function () {
var _local2 = _ymouse - startpos[1];
if (_xmouse > mc_roll._x) {
_local2 = -_local2;
}
startpos = [_xmouse, _ymouse];
if (zwiep_down and (_local2 >= 10)) {
if (_local2 > current_speed) {
current_speed = Math.min(max_speed, Math.abs(_local2));
this.onEnterFrame();
}
} else if (zwiep_up and (_local2 <= -10)) {
if (_local2 < current_speed) {
current_speed = Math.max(-max_speed, _local2);
this.onEnterFrame();
}
} else {
current_speed = 0;
trail = trail + _local2;
showRoll();
}
};
};
this.onMouseUp = function () {
if ((remainder < (perimeter_min / 2)) and ((getTimer() - last_up) < double_click_interval)) {
trail = 0;
current_speed = 0;
showRoll();
}
last_up = getTimer();
this.onMouseMove = null;
if (remainder < (perimeter_min / 2)) {
current_speed = 5;
}
};
this.onEnterFrame = function () {
if (Math.abs(current_speed) > 0) {
trail = trail + current_speed;
showRoll();
if (remainder < (perimeter_min / 2)) {
current_speed = Math.min(max_speed, current_speed * gravity);
} else {
current_speed = current_speed * friction;
}
if (Math.abs(current_speed) < min_speed) {
current_speed = 0;
}
if ((trail - last_sound) > sound_dist) {
playSound();
last_sound = trail;
}
} else {
last_sound = trail;
}
};
function trailToRadius(t_cur, t_max, r_min, thickness) {
var _local1 = Math.sqrt(((thickness * (t_max - t_cur)) / Math.PI) + Math.pow(r_min, 2));
return(_local1);
}
function getPerspectiveAngle(x, y) {
var _local2 = O2.x + ((x - O.x) * persp_factor);
var _local1 = O2.y + ((y - O.y) * persp_factor);
var _local5 = _local2 - x;
var _local3 = _local1 - y;
var _local4 = Math.atan2(_local3, _local5);
return(_local4);
}
function drawRoll(mc, radius_cur, trail_len) {
var _local1 = Math;
var _local15 = _local1.min((2 * Stage.height) - O.y, trail_len);
radius_cur = _local1.max(radius_cur, radius_min);
var _local4 = radius_cur * persp_factor;
var _local11 = trail_len % sheet_length;
var _local14 = sheet_length / radius_cur;
var _local21 = (sheet_length - _local11) / radius_cur;
var _local13 = _local1.round((roll_length + (1 * sheet_length)) - trail_len);
var _local23 = getPerspectiveAngle(0, -radius_cur) + (Math.PI/2);
var _local12 = O.clone();
_local12.offset(radius_cur * Math.cos(_local23), radius_cur * Math.sin(_local23));
var _local22 = O2.clone();
_local22.offset(_local4 * Math.cos(_local23), _local4 * Math.sin(_local23));
_local23 = getPerspectiveAngle(0, radius_cur) - (Math.PI/2);
var _local20 = O.clone();
_local20.offset(radius_cur * Math.cos(_local23), radius_cur * Math.sin(_local23));
var _local17 = O2.clone();
_local17.offset(_local4 * Math.cos(_local23), _local4 * Math.sin(_local23));
mc.clear();
var _local5 = _local1.min(_local1.PI, (_local13 / radius_cur) - _local1.PI);
if (_local5 > (_local23 + (2 * _local1.PI))) {
var _local19 = 360 - ((180 * _local5) / _local1.PI);
mc.lineStyle(1, color_under, 100);
mc.beginFill(color_under, 100);
mc.moveTo(_local20.x, _local20.y);
mc.lineTo(_local17.x, _local17.y);
mc.drawArc(_local17.x, _local17.y, _local4, _local19 - (((-_local23) / _local1.PI) * 180), ((-_local23) / _local1.PI) * 180);
var _local18 = new flash.geom.Point(O.x + (radius_cur * _local1.cos(_local5)), O.y + (radius_cur * _local1.sin(_local5)));
mc.lineTo(_local18.x, _local18.y);
mc.drawArc(_local18.x, _local18.y, radius_cur, (-((_local23 / _local1.PI) * 180)) - _local19, _local19);
mc.endFill();
}
if (_local13 > perimeter_min) {
mc.lineStyle(1, color_lines, 100);
_local23 = getPerspectiveAngle(0, radius_cur) + (2.5 * _local1.PI);
_local5 = (_local21 + (_local14 * _local1.ceil((_local23 - _local21) / _local14))) - _local1.PI;
while (_local5 < _local1.PI) {
var _local10 = new flash.geom.Point(O.x + (radius_cur * _local1.cos(_local5)), O.y + (radius_cur * _local1.sin(_local5)));
var _local9 = new flash.geom.Point(O2.x + (_local4 * _local1.cos(_local5)), O2.y + (_local4 * _local1.sin(_local5)));
drawDashedLine(mc, _local10, _local9, dash_pattern);
_local5 = _local5 + _local14;
}
}
if (_local13 > perimeter_min) {
mc.lineStyle(0, 16777215, 0);
mc.beginFill(color_side, 100);
mc.moveTo(O.x, O.y);
mc.drawOval(O.x, O.y, radius_cur);
mc.endFill();
mc.beginFill(color_lines, 100);
mc.moveTo(O.x, O.y);
mc.drawOval(O.x, O.y, radius_min);
mc.endFill();
} else {
_local23 = getPerspectiveAngle(0, radius_cur) + (1.5 * _local1.PI);
var _local6 = (_local13 / radius_cur) - _local1.PI;
if (_local6 > (-_local23)) {
var _local18 = new flash.geom.Point(O.x + (radius_cur * _local1.cos(_local6)), O.y + (radius_cur * _local1.sin(_local6)));
_local23 = getPerspectiveAngle(0, -radius_cur) + (0.5 * _local1.PI);
mc.endFill();
mc.lineStyle(1, color_side, 100);
mc.moveTo(_local12.x, _local12.y);
mc.drawArc(_local12.x, _local12.y, radius_cur, ((_local23 / _local1.PI) * 180) - ((_local6 / _local1.PI) * 180), ((-_local23) / _local1.PI) * 180);
mc.moveTo(_local12.x, _local12.y);
}
}
mc.lineStyle(0, color_trail, 100);
mc.beginFill(color_trail, 100);
if (_local13 < (perimeter_min / 4)) {
if (_local13 > 0) {
mc.moveTo((O.x - radius_cur) + correctie_rechte_stuk, O.y);
mc.lineTo(O.x - radius_cur, O.y + _local15);
mc.lineTo(O2.x - _local4, O2.y + (_local15 * persp_factor));
mc.lineTo(O2.x - _local4, O2.y);
var _local6 = ((_local1.PI * 2) * _local13) / perimeter_min;
mc.drawArc(O2.x - _local4, O2.y, _local4, -((_local6 / _local1.PI) * 180), 180);
var _local18 = new flash.geom.Point(O.x + (radius_cur * _local1.cos(_local6 - _local1.PI)), O.x + (radius_cur * _local1.sin(_local6 - _local1.PI)));
mc.lineTo(_local18.x, _local18.y);
mc.drawArc(_local18.x, _local18.y, radius_cur, 180 + (((_local6 / _local1.PI) * 180) - 180), -(((_local6 / _local1.PI) * 180) - 180));
} else {
mc.moveTo((O.x - radius_cur) + correctie_rechte_stuk, O.y - _local13);
mc.lineTo(O.x - radius_cur, O.y + _local15);
mc.lineTo(O2.x - _local4, O2.y + (_local15 * persp_factor));
mc.lineTo(O2.x - _local4, O2.y - _local13);
}
} else {
mc.moveTo((O.x - radius_cur) + correctie_rechte_stuk, O.y);
mc.lineTo(O.x - radius_cur, O.y + _local15);
mc.lineTo(O2.x - _local4, O2.y + (_local15 * persp_factor));
mc.lineTo(O2.x - _local4, O2.y);
_local23 = getPerspectiveAngle(0, -radius_cur) - (_local1.PI / 2);
if (_local23 < (-_local1.PI)) {
_local23 = _local23 + (2 * _local1.PI);
}
mc.drawArc(O2.x - _local4, O2.y, _local4, -((_local23 / _local1.PI) * 180), 180);
mc.lineTo(_local12.x, _local12.y);
mc.drawArc(_local12.x, _local12.y, radius_cur, (_local23 / _local1.PI) * 180, -180 - ((_local23 / _local1.PI) * 180));
}
mc.endFill();
mc.lineStyle(1, color_lines, 100);
trail_len = _local1.min(trail_len, (trail_len % sheet_length) + (6 * sheet_length));
var _local7 = 1;
while (_local7 <= (trail_len / sheet_length)) {
var _local10 = new flash.geom.Point(O.x - radius_cur, (O.y + trail_len) - (_local7 * sheet_length));
var _local9 = new flash.geom.Point(O2.x - _local4, O2.y + ((trail_len - (_local7 * sheet_length)) * persp_factor));
drawDashedLine(mc, _local10, _local9, dash_pattern);
_local7++;
}
_local23 = getPerspectiveAngle(0, -radius_cur) + (_local1.PI / 2);
var _local16 = (-_local23) * radius_cur;
_local7 = 1;
while (_local7 < ((_local11 + _local16) / sheet_length)) {
var _local6 = _local1.PI + (((_local7 * sheet_length) - _local11) / radius_cur);
var _local10 = new flash.geom.Point(O.x + (radius_cur * _local1.cos(_local6)), O.y + (radius_cur * _local1.sin(_local6)));
var _local9 = new flash.geom.Point(O2.x + (_local4 * _local1.cos(_local6)), O2.y + (_local4 * _local1.sin(_local6)));
drawDashedLine(mc, _local10, _local9, dash_pattern);
_local7++;
}
}
function drawDashedLine(mc, p0, p1, pattern) {
var _local3 = 3;
var _local5 = (p1.x - p0.x) / (p1.y - p0.y);
var _local2 = p0.clone();
var _local1 = p1.clone();
var _local4 = ((_local1.x < _local2.x) ? -1 : 1);
_local2.x = _local2.x + (_local3 * _local4);
_local1.x = _local1.x - (_local3 * _local4);
var _local9 = ((_local1.y < _local2.y) ? -1 : 1);
_local2.y = _local2.y + ((_local3 / _local5) * _local4);
_local1.y = _local1.y - ((_local3 / _local5) * _local4);
mc.dashTo(_local2.x, _local2.y, _local1.x, _local1.y, pattern[0], pattern[1], true);
}
function drawCircle(mc, p, rx, ry) {
var _local2 = p.x;
var _local1 = p.y;
var _local8 = Math;
var _local5 = _local8.tan(_local8.PI / 8);
var _local6 = _local8.sin(_local8.PI / 4);
mc.moveTo(_local2 + rx, _local1);
mc.curveTo(rx + _local2, (_local5 * ry) + _local1, (_local6 * rx) + _local2, (_local6 * ry) + _local1);
mc.curveTo((_local5 * rx) + _local2, ry + _local1, _local2, ry + _local1);
mc.curveTo(((-_local5) * rx) + _local2, ry + _local1, ((-_local6) * rx) + _local2, (_local6 * ry) + _local1);
mc.curveTo((-rx) + _local2, (_local5 * ry) + _local1, (-rx) + _local2, _local1);
mc.curveTo((-rx) + _local2, ((-_local5) * ry) + _local1, ((-_local6) * rx) + _local2, ((-_local6) * ry) + _local1);
mc.curveTo(((-_local5) * rx) + _local2, (-ry) + _local1, _local2, (-ry) + _local1);
mc.curveTo((_local5 * rx) + _local2, (-ry) + _local1, (_local6 * rx) + _local2, ((-_local6) * ry) + _local1);
mc.curveTo(rx + _local2, ((-_local5) * ry) + _local1, rx + _local2, _local1);
}
var dash_pattern = [4, 6];
var color_lines = 0;
var color_trail = 16777215;
var color_side = 14408667;
var color_under = 5460819;
var cookie_enabled = true;
var trail = 250;
var radius_max = 225;
var radius_min = 70;
var sheet_length = 350;
var sheet_count = 100;
var scrollspeed = 10;
var keyspeed = 20;
var autospeed = 20;
var friction = 0.97;
var min_speed = 0.5;
var max_speed = 50;
var gravity = 1.1;
var zwiep_up = true;
var zwiep_down = true;
var correctie_rechte_stuk = -0.5;
var double_click_interval = 350;
var sound_dist = 60;
var trail_min = 225;
if (cookie_enabled) {
var so = SharedObject.getLocal("papertoilet", "/");
if (so.data.trail != undefined) {
trail = so.data.trail;
}
}
var trail_max = ((sheet_count - 2) * sheet_length);
var O = (new flash.geom.Point(0, 0));
var O2 = (new flash.geom.Point(-222, -45));
var persp_factor = 0.92;
var current_speed = 0;
var last_up = 0;
var radius_cur = radius_max;
var roll_length = (sheet_count * sheet_length);
var perimeter_min = ((radius_min * 2) * Math.PI);
var remainder = Math.round((roll_length + (1 * sheet_length)) - trail);
var thickness = ((Math.PI / roll_length) * (Math.pow(radius_max, 2) - Math.pow(radius_min, 2)));
var trail_prev = -1;
mc_roll = _root.createEmptyMovieClip("mc_roll", 0);
mc_roll._x = 507;
mc_roll._y = 295;
showRoll();
Symbol 1 MovieClip Frame 1
function onSelectURLItem(obj, menuItem) {
getURL (menuItem.url, "_blank");
}
var items = [];
items[0] = {label:"paper toilet .com"};
items[1] = {label:"by Rafa\u00EBl Rozendaal, 2006", url:"http://www.newrafael.com"};
items[2] = {label:"programming by Reinier Feijen", url:"http://www.boxofchocolates.nl"};
var defaultItems = {zoom:true, quality:true, loop:false, play:false, print:true, rewind:false, forwardAndBack:false, save:true};
var enableTextItems = false;
var myContextMenu = new ContextMenu();
var i = 0;
while (i < items.length) {
var item = new ContextMenuItem(items[i].label, function () {
});
if (items[i].separatorBefore != null) {
item.separatorBefore = items[i].separatorBefore;
}
if (items[i].url != null) {
item.url = items[i].url;
item.onSelect = onSelectURLItem;
} else {
item.enabled = enableTextItems;
}
myContextMenu.customItems.push(item);
i++;
}
for (var s in defaultItems) {
myContextMenu.builtInItems[s] = defaultItems[s];
}
this._parent.menu = myContextMenu;