Section 1
//MainTimeline (machinemusicv2_fla.MainTimeline)
package machinemusicv2_fla {
import flash.events.*;
import flash.display.*;
import flash.media.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.printing.*;
import flash.system.*;
import flash.text.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip {
public var my_menu:ContextMenu;
public var bar:Array;
public var specguide:Sprite;
public var cloud:Sprite;
public var kick:Sprite;
public var insp;
public var i;
public var bytes:ByteArray;
public var intro:Intro;
public var loop:Loop;
public var thissong;
public var looping;
public var lastval:Array;
public var version;
public var hat1:Sprite;
public var hat2:Sprite;
public var hat3:Sprite;
public var credit;
public var soundChannel:SoundChannel;
public var spectrumArray:Array;
public var snare1:Sprite;
public var snare2:Sprite;
public var maxval;
public var songsource;
public var shaker1:Sprite;
public var pattern:Array;
public var shaker2:Sprite;
public var cloudbitmap:Cloud;
public var testguide:Sprite;
public var bguide:MovieClip;
public var huerot;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2, 2, frame3);
}
public function colorFromHue(_arg1:Number):Number{
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
_local5 = Math.floor((_arg1 / 120));
_local6 = (_arg1 % 120);
if (_local6 < 60){
_local7 = 0xFF;
_local8 = Math.round((_local6 * (0xFF / 60)));
} else {
_local8 = 0xFF;
_local7 = Math.round(((_local6 - 60) * (0xFF / 60)));
};
switch (_local5){
case 0:
_local2 = _local7;
_local3 = _local8;
_local4 = 0;
break;
case 1:
_local2 = 0;
_local3 = _local7;
_local4 = _local8;
break;
case 2:
_local2 = _local8;
_local3 = 0;
_local4 = _local7;
break;
};
return (hexFromChannels(_local2, _local3, _local4));
}
public function hexFromChannels(_arg1:Number, _arg2:Number, _arg3:Number):Number{
var _local4:*;
_local4 = (_arg1 << 16);
_local4 = (_local4 + (_arg2 << 8));
_local4 = (_local4 + _arg3);
return (_local4);
}
function frame3(){
update();
gotoAndPlay(2);
}
public function updatedrums(){
var _local1:*;
_local1 = getStep();
shaker2.alpha = isActive(0, _local1, shaker2.alpha);
shaker1.alpha = isActive(1, _local1, shaker1.alpha);
hat3.alpha = isActive(2, _local1, hat3.alpha);
hat2.alpha = isActive(3, _local1, hat2.alpha);
hat1.alpha = isActive(4, _local1, hat1.alpha);
snare2.alpha = isActive(5, _local1, snare2.alpha);
snare1.alpha = isActive(6, _local1, snare1.alpha);
kick.alpha = isActive(7, _local1, kick.alpha);
}
function frame2(){
update();
}
function frame1(){
my_menu = new ContextMenu();
my_menu.hideBuiltInItems();
version = new ContextMenuItem("Machine Music rev.2");
version.enabled = false;
credit = new ContextMenuItem("Rubber NAND 2015");
credit.enabled = false;
insp = new ContextMenuItem("inspired by TheGlasshouseWithButterfly.swf by [R-H]!mfGZNk0vaI");
insp.separatorBefore = true;
insp.enabled = false;
songsource = new ContextMenuItem("Original music: Machinarium Soundtrack 11 - The Glasshouse With Butterfly (Tomas Dvorak)");
songsource.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openSSLink);
songsource.separatorBefore = true;
thissong = new ContextMenuItem("This remix will go up here when it's finished");
thissong.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openremixlink);
my_menu.customItems.push(version, credit, insp, songsource, thissong);
contextMenu = my_menu;
soundChannel = new SoundChannel();
intro = new Intro();
loop = new Loop();
looping = false;
soundChannel = intro.play();
soundChannel.addEventListener(Event.SOUND_COMPLETE, introEndHandler);
testguide = new Sprite();
bguide.addChild(testguide);
testguide.x = 246;
testguide.y = 199;
specguide = new Sprite();
bguide.addChild(specguide);
specguide.x = 0;
specguide.y = 0;
specguide.rotation = 0;
spectrumArray = new Array();
i = 0;
while (i < 0x0100) {
spectrumArray.push(new Sprite());
specguide.addChild(spectrumArray[i]);
spectrumArray[i].x = Math.floor((i * 5));
i++;
};
huerot = 0;
i = 0;
while (i < 0x0100) {
drawBox(i, Math.random());
i++;
};
cloudbitmap = new Cloud(0x0500, 720);
cloud = new Sprite();
cloud.graphics.beginBitmapFill(cloudbitmap);
cloud.graphics.drawRect(0, 0, 0x0500, 1440);
cloud.graphics.endFill();
bguide.addChild(cloud);
cloud.alpha = 0.6;
maxval = 0.5;
lastval = new Array(0x0100);
i = 0;
while (i < 0x0100) {
lastval[i] = 0;
i++;
};
bytes = new ByteArray();
pattern = new Array(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 9, 10, 9, 11, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 9, 10, 9, 10, 14, 15, 15, 15, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 16, 17, 18, 19, 16, 17, 18, 19, 16, 17, 18, 19, 16, 17, 18, 19);
bar = new Array();
bar.push(new Array(128, 8, 0, 16, 32, 16, 0, 8, 128, 16, 8, 32, 0, 8, 128, 16));
bar.push(new Array(128, 8, 0, 16, 32, 16, 0, 8, 128, 16, 8, 32, 0, 8, 128, 16));
bar.push(new Array(128, 8, 0, 16, 32, 16, 0, 8, 128, 16, 8, 32, 0, 8, 128, 16));
bar.push(new Array(128, 8, 0, 16, 32, 16, 0, 8, 4, 16, 136, 4, 32, 8, 128, 16));
bar.push(new Array(128, 8, 0, 16, 32, 16, 0, 8, 128, 16, 8, 32, 0, 8, 128, 16));
bar.push(new Array(128, 8, 0, 16, 32, 16, 0, 8, 128, 16, 8, 32, 128, 9, 128, 16));
bar.push(new Array(128, 8, 0, 16, 32, 16, 0, 8, 128, 16, 8, 32, 0, 8, 128, 16));
bar.push(new Array(128, 8, 0, 16, 32, 16, 0, 8, 4, 16, 136, 4, 32, 8, 128, 16));
bar.push(new Array(17, 10, 5, 18, 9, 18, 1, 6, 17, 10, 5, 18, 1, 6, 17, 6));
bar.push(new Array(17, 10, 5, 18, 9, 18, 1, 6, 17, 10, 5, 18, 1, 6, 17, 2));
bar.push(new Array(17, 10, 5, 18, 137, 18, 65, 6, 17, 10, 69, 18, 129, 6, 81, 6));
bar.push(new Array(129, 10, 5, 18, 65, 18, 5, 10, 129, 6, 9, 66, 17, 10, 133, 18));
bar.push(new Array(129, 10, 5, 18, 65, 146, 5, 6, 145, 18, 133, 42, 17, 42, 133, 10));
bar.push(new Array(9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
bar.push(new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
bar.push(new Array(129, 10, 5, 18, 65, 18, 133, 10, 1, 74, 5, 66, 145, 138, 5, 82));
bar.push(new Array(145, 10, 5, 18, 65, 146, 5, 17, 145, 82, 133, 42, 17, 42, 133, 18));
bar.push(new Array(129, 10, 5, 18, 65, 18, 133, 10, 1, 74, 5, 66, 145, 138, 5, 82));
bar.push(new Array(145, 10, 5, 18, 65, 146, 5, 17, 145, 82, 133, 42, 145, 106, 5, 82));
kick = new Sprite();
kick.graphics.beginFill(0xFFFFFF);
kick.graphics.drawRect(0, 0, 106, 226);
kick.graphics.endFill();
testguide.addChild(kick);
kick.x = 0;
kick.alpha = 0;
snare1 = new Sprite();
snare1.graphics.beginFill(0xFFFFFF);
snare1.graphics.drawRect(0, 0, 132, 226);
snare1.graphics.endFill();
testguide.addChild(snare1);
snare1.x = 106;
snare1.alpha = 0;
snare2 = new Sprite();
snare2.graphics.beginFill(0xFFFFFF);
snare2.graphics.drawRect(0, 0, 132, 226);
snare2.graphics.endFill();
testguide.addChild(snare2);
snare2.x = 238;
snare2.alpha = 0;
hat1 = new Sprite();
hat1.graphics.beginFill(0xFFFFFF);
hat1.graphics.drawRect(0, 0, 114, 226);
hat1.graphics.endFill();
testguide.addChild(hat1);
hat1.x = 370;
hat1.alpha = 0;
hat2 = new Sprite();
hat2.graphics.beginFill(0xFFFFFF);
hat2.graphics.drawRect(0, 0, 105, 226);
hat2.graphics.endFill();
testguide.addChild(hat2);
hat2.x = 484;
hat2.alpha = 0;
hat3 = new Sprite();
hat3.graphics.beginFill(0xFFFFFF);
hat3.graphics.drawRect(0, 0, 85, 226);
hat3.graphics.endFill();
testguide.addChild(hat3);
hat3.x = 589;
hat3.alpha = 0;
shaker1 = new Sprite();
shaker1.graphics.beginFill(0xFFFFFF);
shaker1.graphics.drawRect(0, 0, 94, 133);
shaker1.graphics.endFill();
testguide.addChild(shaker1);
shaker1.x = 674;
shaker1.alpha = 0;
shaker2 = new Sprite();
shaker2.graphics.beginFill(0xFFFFFF);
shaker2.graphics.drawRect(0, 0, 94, 93);
shaker2.graphics.endFill();
testguide.addChild(shaker2);
shaker2.x = 674;
shaker2.y = 133;
shaker2.alpha = 0;
}
public function update(){
var _local1:*;
var _local2:*;
SoundMixer.computeSpectrum(bytes, false, 0);
_local1 = 0;
while (_local1 < 0x0100) {
_local2 = bytes.readFloat();
lastval[_local1] = ((_local2)>lastval[_local1]) ? _local2 : (lastval[_local1] * 0.95);
if (_local2 > maxval){
maxval = _local2;
};
drawBox(_local1, (lastval[_local1] / maxval));
_local1++;
};
maxval = (maxval * 0.99);
cloud.y = (cloud.y - 1);
if (cloud.y <= -720){
cloud.y = 0;
};
huerot++;
if (huerot > 0xFF){
huerot = 0;
};
if (looping){
updatedrums();
};
}
public function isActive(_arg1:Number, _arg2:Number, _arg3:Number):Number{
if (((1 << _arg1) & _arg2) > 0){
return (0.9);
};
return ((_arg3 * 0.9));
}
public function getStep():Number{
var _local1:*;
var _local2:*;
var _local3:*;
_local1 = (soundChannel.position % loop.length);
_local2 = pattern[((Math.floor((_local1 / 2400)))<80) ? Math.floor((_local1 / 2400)) : 0];
_local3 = Math.floor(((_local1 % 2400) / 150));
return (bar[(_local2 - 1)][_local3]);
}
public function openSSLink(_arg1:ContextMenuEvent):void{
navigateToURL(new URLRequest("https://soundcloud.com/minorityrecords/sets/machinarium-ost"));
}
public function introEndHandler(_arg1:Event):void{
soundChannel.removeEventListener(Event.SOUND_COMPLETE, introEndHandler);
soundChannel = loop.play(0, int.MAX_VALUE);
looping = true;
}
public function maxHeight(_arg1:Number):Number{
if (_arg1 < 176){
return (143);
};
if (_arg1 < 251){
return (187);
};
if (_arg1 < 1010){
return (426);
};
if (_arg1 < 1140){
return (204);
};
if (_arg1 < 1246){
return (137);
};
return (204);
}
public function openremixlink(_arg1:ContextMenuEvent):void{
navigateToURL(new URLRequest("https://soundcloud.com/9c5"));
}
public function drawBox(_arg1:Number, _arg2:Number){
spectrumArray[_arg1].graphics.clear();
spectrumArray[_arg1].graphics.beginFill(colorFromHue(Math.floor(((((_arg1 + huerot) % 0x0100) / 0x0100) * 360))));
spectrumArray[_arg1].graphics.drawRect(0, 0, 5, Math.round((_arg2 * maxHeight(spectrumArray[_arg1].x))));
spectrumArray[_arg1].graphics.endFill();
}
}
}//package machinemusicv2_fla
Section 2
//Cloud (Cloud)
package {
import flash.display.*;
public dynamic class Cloud extends BitmapData {
public function Cloud(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 3
//Intro (Intro)
package {
import flash.media.*;
public dynamic class Intro extends Sound {
}
}//package
Section 4
//Loop (Loop)
package {
import flash.media.*;
public dynamic class Loop extends Sound {
}
}//package