Section 1
//MainTimeline (machinemusic_fla.MainTimeline)
package machinemusic_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 version;
public var spectrumArray:Array;
public var my_menu:ContextMenu;
public var soundChannel:SoundChannel;
public var specguide:Sprite;
public var cloud:Sprite;
public var maxval:Array;
public var i;
public var bytes:ByteArray;
public var songsource;
public var insp;
public var intro:Intro;
public var testguide:MovieClip;
public var thissong;
public var looping;
public var loop:Loop;
public var bguide:MovieClip;
public var cloudbitmap:Cloud;
public var huerot;
public var lastval:Array;
public var credit;
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 openSSLink(_arg1:ContextMenuEvent):void{
navigateToURL(new URLRequest("https://soundcloud.com/minorityrecords/sets/machinarium-ost"));
}
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);
}
function frame2(){
update();
}
public function introEndHandler(_arg1:Event):void{
soundChannel.removeEventListener(Event.SOUND_COMPLETE, introEndHandler);
soundChannel = loop.play(0, int.MAX_VALUE);
looping = true;
}
function frame1(){
my_menu = new ContextMenu();
my_menu.hideBuiltInItems();
version = new ContextMenuItem("Machine Music rev.1");
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);
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 = new Array(0x0100);
lastval = new Array(0x0100);
i = 0;
while (i < 0x0100) {
maxval[i] = 0.5;
lastval[i] = 0;
i++;
};
bytes = new ByteArray();
}
public function openremixlink(_arg1:ContextMenuEvent):void{
navigateToURL(new URLRequest("https://soundcloud.com/9c5"));
}
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 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[_local1]){
maxval[_local1] = _local2;
};
drawBox(_local1, (lastval[_local1] / maxval[_local1]));
_local1++;
};
cloud.y = (cloud.y - 1);
if (cloud.y <= -720){
cloud.y = 0;
};
huerot++;
if (huerot > 0xFF){
huerot = 0;
};
}
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 machinemusic_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