Frame 1
var duchampmain = (new RRDuchamp.Main(mc_total));
duchampmain.start();
Symbol 34 MovieClip Frame 1
function onSelectURLItem(obj, menuItem) {
getURL (menuItem.url, "_blank");
}
var items = [];
items[0] = {label:"le duchamp .com"};
items[1] = {label:"by Rafa\u00EBl Rozendaal, 2008", url:"http://www.newrafael.com"};
items[2] = {label:"programming by Reinier Feijen", url:"http://www.boxofchocolates.nl"};
var defaultItems = {zoom:false, quality:false, loop:false, play:false, print:false, rewind:false, forwardAndBack:false, save:false};
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;
Symbol 35 MovieClip [__Packages.RRDuchamp.Main] Frame 0
class RRDuchamp.Main
{
var basemc, wheel, frame_step, frame_last, interval_main;
function Main (mc) {
basemc = mc;
wheel = new RRDuchamp.Wheel(basemc.mc_wheel);
}
function start() {
frame_step = 1000 / RRDuchamp.Config.fps;
frame_last = -1000;
resume();
}
function pause() {
clearInterval(interval_main);
}
function resume() {
clearInterval(interval_main);
if (!RRDuchamp.Config.bool_use_flash_framerate) {
interval_main = setInterval(this, "step", 2);
} else {
var cont = this;
basemc.onEnterFrame = function () {
cont.update();
};
}
}
function step() {
if ((frame_last + frame_step) <= getTimer()) {
frame_last = getTimer();
update();
}
}
function update() {
wheel.update();
updateAfterEvent();
}
}
Symbol 36 MovieClip [__Packages.RRDuchamp.Wheel] Frame 0
class RRDuchamp.Wheel
{
var basemc, center, tics, speed_cur, speed_min, speed_max, speed_factor, friction, friction_rollover, rolling_over, dragging, drag_last, drag_last_angle;
function Wheel (mc) {
basemc = mc;
center = new flash.geom.Point(basemc._x, basemc._y);
tics = new RRDuchamp.TicManager(basemc._parent);
speed_cur = 0;
speed_min = (RRDuchamp.Config.speed_min / 180) * Math.PI;
speed_max = (RRDuchamp.Config.speed_max / 180) * Math.PI;
speed_factor = RRDuchamp.Config.speed_factor;
friction = RRDuchamp.Config.friction;
friction_rollover = RRDuchamp.Config.friction_rollover;
var cont = this;
mc.onRollOver = function () {
cont.onRollOver();
};
mc.onRollOut = function () {
cont.onRollOut();
};
mc.onPress = function () {
cont.onPress();
};
mc.onRelease = function () {
cont.onRelease();
};
mc.onMouseMove = function () {
cont.onMouseMove();
};
mc.onReleaseOutside = mc.onRelease;
mc.onDragOut = mc.onRelease;
mc.useHandCursor = false;
}
function update() {
if (speed_cur != 0) {
var _local2 = ((speed_cur < 0) ? -1 : 1);
var _local3 = (rolling_over ? (friction_rollover) : (friction));
speed_cur = _local2 * Math.min(speed_max, Math.abs(speed_cur * _local3));
if (Math.abs(speed_cur) < speed_min) {
speed_cur = 0;
}
changeRotation(speed_cur);
}
tics.update(speed_cur);
}
function changeRotation(d) {
basemc._rotation = basemc._rotation + ((d / Math.PI) * 180);
basemc._parent.mc_shadow.mc_wheel._rotation = basemc._rotation;
}
function onRollOver() {
rolling_over = true;
}
function onRollOut() {
rolling_over = false;
}
function onPress() {
if ((!RRDuchamp.Config.bool_spokes_only) || (basemc.mc_hitarea_spokes.hitTest(_xmouse, _ymouse, true))) {
speed_cur = 0;
dragging = true;
drag_last = mouse_pos;
drag_last_angle = 0;
rolling_over = false;
}
}
function onRelease() {
if (dragging) {
speed_cur = speed_factor * drag_last_angle;
dragging = false;
}
}
function onMouseMove() {
if (rolling_over) {
if ((!RRDuchamp.Config.bool_spokes_only) || (basemc.mc_hitarea_spokes.hitTest(_xmouse, _ymouse, true))) {
basemc.useHandCursor = true;
} else {
basemc.useHandCursor = false;
}
}
if (dragging) {
var _local2 = mouse_pos;
drag_last_angle = calcAngleForPoints(drag_last, _local2);
drag_last = _local2;
changeRotation(drag_last_angle);
}
}
function calcAngleForPoints(p0, p1) {
var _local3 = p0.subtract(center);
var _local5 = Math.atan2(_local3.y, _local3.x);
var _local2 = p1.subtract(center);
var _local4 = Math.atan2(_local2.y, _local2.x);
return(_local4 - _local5);
}
function get mouse_pos() {
return(new flash.geom.Point(basemc._parent._xmouse, basemc._parent._ymouse));
}
}
Symbol 37 MovieClip [__Packages.RRDuchamp.TicManager] Frame 0
class RRDuchamp.TicManager
{
var basemc, sound_bg, sound_tic, interval_calc, time_between, sound_nr, last_start;
function TicManager (mc) {
basemc = mc;
sound_bg = new Sound(basemc.createEmptyMovieClip("soundlayer0", 10));
sound_bg.attachSound("wheel01");
sound_bg.onSoundComplete = function () {
this.start(0, 9999999);
};
sound_bg.setVolume(0);
sound_bg.start(0, 9999999);
sound_tic = new Sound(basemc.createEmptyMovieClip("soundlayer1", 11));
var _local2 = SharedObject.getLocal("rrduchamp");
if (_local2.data.vol != null) {
sound_tic.setVolume(_local2.data.vol);
}
Key.addListener(this);
interval_calc = setInterval(this, "step", 5);
}
function onKeyDown() {
var _local2 = Key.getCode();
if (_local2 == 187) {
sound_tic.setVolume(sound_tic.getVolume() + 10);
} else if (_local2 == 189) {
sound_tic.setVolume(sound_tic.getVolume() - 10);
} else if (_local2 == 83) {
if (sound_tic.getVolume() > 0) {
sound_tic.setVolume(0);
} else {
sound_tic.setVolume(100);
}
}
var _local3 = SharedObject.getLocal("rrduchamp");
_local3.data.vol = sound_tic.getVolume();
}
function update(speed) {
if (speed != 0) {
time_between = calcIntervalForSpeed(speed);
sound_nr = calcSoundNrForSpeed(speed);
} else {
delete last_start;
delete time_between;
}
}
function step() {
if (last_start == null) {
if (time_between != null) {
doTic();
}
} else if ((last_start + time_between) <= getTimer()) {
doTic();
}
}
function doTic() {
last_start = getTimer();
sound_tic.attachSound("wheel" + String("00" + (1 + sound_nr)).substr(-2));
sound_tic.start();
}
function calcIntervalForSpeed(s) {
var _local1 = Math.abs((s / Math.PI) * 180);
var _local3 = RRDuchamp.Config.degrees_per_tic;
var _local4 = Math.max(1, _local3 / _local1);
var _local2 = Math.min(RRDuchamp.Config.interval_max, Math.max(RRDuchamp.Config.interval_min, _local4 * (1000 / RRDuchamp.Config.fps)));
return(Math.round(_local2));
}
function calcSoundNrForSpeed(s) {
var _local2 = Math.abs((s / Math.PI) * 180);
var _local5 = ((1000 * RRDuchamp.Config.fps) * RRDuchamp.Config.degrees_per_tic) / RRDuchamp.Config.speed_min;
var _local3 = (time_between - RRDuchamp.Config.interval_min) / (_local5 - RRDuchamp.Config.interval_min);
var _local4 = Math.floor(_local3 * RRDuchamp.Config.sound_count);
return(_local4);
}
}
Symbol 38 MovieClip [__Packages.RRDuchamp.Config] Frame 0
class RRDuchamp.Config
{
function Config () {
}
static var bool_debug = true;
static var bool_use_flash_framerate = false;
static var fps = 30;
static var bool_spokes_only = true;
static var speed_factor = 1;
static var speed_max = 36;
static var speed_min = 0.2;
static var friction = 0.992;
static var friction_rollover = 0.95;
static var sound_count = 20;
static var interval_min = 80;
static var interval_max = 1800;
static var degrees_per_tic = 30;
}