Frame 1
Main.main(this);
Symbol 20480 MovieClip [__Packages.mx.events.EventDispatcher] Frame 0
class mx.events.EventDispatcher
{
function EventDispatcher () {
}
static function _removeEventListener(queue, event, handler) {
if (queue != undefined) {
var _local5 = queue.length;
var _local6 = 0;
for ( ; _local6 < _local5 ; _local6++) {
var _local7 = queue[_local6];
if (_local7 == handler) {
queue.splice(_local6, 1);
return(undefined);
}
}
}
}
static function initialize(object) {
if (_fEventDispatcher == undefined) {
_fEventDispatcher = new mx.events.EventDispatcher();
}
object.addEventListener = _fEventDispatcher.addEventListener;
object.removeEventListener = _fEventDispatcher.removeEventListener;
object.dispatchEvent = _fEventDispatcher.dispatchEvent;
object.dispatchQueue = _fEventDispatcher.dispatchQueue;
}
function dispatchQueue(queueObj, eventObj) {
var _local4 = "__q_" + eventObj.type;
var _local5 = queueObj[_local4];
if (_local5 != undefined) {
for (var _local6 in _local5) {
var _local7 = _local5[_local6];
var _local8 = typeof(_local7);
if ((_local8 == "object") || (_local8 == "movieclip")) {
if (_local7.handleEvent != undefined) {
_local7.handleEvent(eventObj);
}
if (_local7[eventObj.type] != undefined) {
if (exceptions[eventObj.type] == undefined) {
_local7[eventObj.type](eventObj);
}
}
} else {
_local7.apply(queueObj, [eventObj]);
}
}
}
}
function dispatchEvent(eventObj) {
if (eventObj.target == undefined) {
eventObj.target = this;
}
this[eventObj.type + "Handler"](eventObj);
dispatchQueue(this, eventObj);
}
function addEventListener(event, handler) {
var _local4 = "__q_" + event;
if (this[_local4] == undefined) {
this[_local4] = new Array();
}
_global.ASSetPropFlags(this, _local4, 1);
_removeEventListener(this[_local4], event, handler);
this[_local4].push(handler);
}
function removeEventListener(event, handler) {
var _local4 = "__q_" + event;
_removeEventListener(this[_local4], event, handler);
}
static var _fEventDispatcher = undefined;
static var exceptions = {move:1, draw:1, load:1};
}
Symbol 20481 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.EventBroadcaster] Frame 0
class org.flashcodersbrighton.drummachine.dmf.EventBroadcaster
{
function EventBroadcaster () {
mx.events.EventDispatcher.initialize(this);
}
function dispatchEvent(ev) {
}
function addEventListener(event, listener) {
}
function removeEventListener(event, listener) {
}
}
Symbol 20482 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.ITrackView] Frame 0
class org.flashcodersbrighton.drummachine.dmf.ITrackView
{
function ITrackView () {
}
}
Symbol 20483 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.BaseTrackView] Frame 0
class org.flashcodersbrighton.drummachine.dmf.BaseTrackView extends org.flashcodersbrighton.drummachine.dmf.EventBroadcaster implements org.flashcodersbrighton.drummachine.dmf.ITrackView
{
var dispatchEvent, trackmodel, rootclip, trackindex, togglefunc, playfunc;
function BaseTrackView () {
super();
}
function initialise() {
}
function createPart(i) {
}
function turnOn(i) {
}
function turnOff(i) {
}
function play(event) {
}
function reset() {
}
function partToggled(i) {
dispatchEvent({type:"changeState", target:this, i:i});
}
function init(trackmodel, rootclip, trackindex) {
this.trackmodel = trackmodel;
this.rootclip = rootclip;
this.trackindex = trackindex;
togglefunc = mx.utils.Delegate.create(this, toggle);
playfunc = mx.utils.Delegate.create(this, play);
trackmodel.addEventListener("changeState", togglefunc);
trackmodel.addEventListener("tick", playfunc);
initialise();
var _local5 = 0;
for ( ; _local5 < trackmodel.PARTS ; _local5++) {
createPart(_local5);
}
refresh();
}
function toggle(event) {
(trackmodel.isPlaying(event.i) ? (turnOn(event.i)) : (turnOff(event.i)));
}
function refresh() {
var _local2 = 0;
for ( ; _local2 < trackmodel.PARTS ; _local2++) {
toggle({target:trackmodel, i:_local2});
}
}
function destroy() {
trackmodel.removeEventListener("changeState", togglefunc);
trackmodel.removeEventListener("tick", playfunc);
reset();
}
}
Symbol 20484 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.PartsView] Frame 0
class org.flashcodersbrighton.drummachine.dmf.PartsView extends org.flashcodersbrighton.drummachine.dmf.BaseTrackView
{
var parts, partclick, trackindex, rootclip, trackmodel, partToggled;
function PartsView () {
super();
}
function initialise() {
parts = new Array();
partclick = mx.utils.Delegate.create(this, partClick);
}
function createPart(i) {
var _local3 = create();
_local3.init(i, trackindex, rootclip, trackmodel);
_local3.addEventListener("click", partclick);
_local3.create();
parts.push(_local3);
}
function turnOn(i) {
parts[i].turnOn();
}
function turnOff(i) {
parts[i].turnOff();
}
function play(event) {
var _local3 = 0;
for ( ; _local3 < parts.length ; _local3++) {
parts[_local3].play(event.target.part == _local3);
}
}
function reset() {
var _local2 = 0;
for ( ; _local2 < parts.length ; _local2++) {
parts[_local2].removeEventListener("click", partclick);
parts[_local2].destroy();
}
initialise();
}
function partClick(event) {
partToggled(event.target.index);
}
function create() {
return(new org.flashcodersbrighton.drummachine.dmf.PartView());
}
}
Symbol 20485 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.PartsView3D] Frame 0
class org.flashcodersbrighton.drummachine.dmf.PartsView3D extends org.flashcodersbrighton.drummachine.dmf.PartsView
{
function PartsView3D () {
super();
org.flashdevelop.utils.FlashConnect.mtrace("PartsView3D", "org.flashcodersbrighton.drummachine.dmf.PartsView3D::PartsView3D", "C:\\Documents and Settings\\arthur\\Desktop\\drumsvn\\DMF\\classes/org/flashcodersbrighton/drummachine/dmf/PartsView3D.as", 9);
}
function create() {
return(new org.flashcodersbrighton.drummachine.dmf.PartView3D());
}
}
Symbol 20486 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.HiResTimer] Frame 0
class org.flashcodersbrighton.drummachine.dmf.HiResTimer extends org.flashcodersbrighton.drummachine.dmf.EventBroadcaster
{
var elapsedTime, silentSound, BPM, tickEventInterval, nextTickEventTime, dispatchEvent;
function HiResTimer (bpm) {
super();
elapsedTime = 0;
setBPM(bpm);
silentSound = new Sound();
silentSound.onLoad = mx.utils.Delegate.create(this, soundReady);
silentSound.loadSound("mp3/silence.mp3");
}
function setBPM(bpm) {
BPM = bpm;
bpm = Math.min(Math.max(bpm, 1), 250);
tickEventInterval = 15 / bpm;
}
function soundReady(event) {
silentSound.setVolume(0);
silentSound.onSoundComplete = mx.utils.Delegate.create(this, triggerSound);
nextTickEventTime = tickEventInterval;
triggerSound();
}
function triggerSound() {
var _local2 = (silentSound.duration / 1000) - 0.001;
silentSound.start(_local2);
internalTick();
}
function internalTick() {
elapsedTime = elapsedTime + INTERNAL_TICK_INTERVAL;
var _local2 = elapsedTime + INTERNAL_TICK_INTERVAL;
if (_local2 > nextTickEventTime) {
dispatchEvent({type:"tick", target:this, offset:nextTickEventTime - elapsedTime});
nextTickEventTime = nextTickEventTime + tickEventInterval;
}
if ((elapsedTime > 10) && (nextTickEventTime > 10)) {
elapsedTime = elapsedTime - 10;
nextTickEventTime = nextTickEventTime - 10;
}
}
var INTERNAL_TICK_INTERVAL = 2048 / 44100;
}
Symbol 20487 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.IPartView] Frame 0
class org.flashcodersbrighton.drummachine.dmf.IPartView
{
function IPartView () {
}
}
Symbol 20488 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.BasePartView] Frame 0
class org.flashcodersbrighton.drummachine.dmf.BasePartView extends org.flashcodersbrighton.drummachine.dmf.EventBroadcaster implements org.flashcodersbrighton.drummachine.dmf.IPartView
{
var trackmodel, trackindex, rootclip, index, dispatchEvent;
function BasePartView (index, trackindex, rootclip, trackmodel) {
super();
}
function init(index, trackindex, rootclip, trackmodel) {
this.trackmodel = trackmodel;
this.trackindex = trackindex;
this.rootclip = rootclip;
this.index = index;
}
function click() {
dispatchEvent({type:"click", target:this});
}
function create() {
}
function play(state) {
}
function turnOn() {
}
function turnOff() {
}
function destroy() {
}
}
Symbol 20489 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.PartView3D] Frame 0
class org.flashcodersbrighton.drummachine.dmf.PartView3D extends org.flashcodersbrighton.drummachine.dmf.BasePartView implements org.flashcodersbrighton.drummachine.dmf.IPartView
{
var world, rootclip, particle, index, trackindex, click;
function PartView3D () {
super();
}
function create() {
world = net.pluginmedia.particles.WorldFactory.getInstance(rootclip._parent);
particle = new net.pluginmedia.particles.Particle3D("ball", rootclip, (index - 8) * 12, (trackindex - 3) * 12, (index - 8) * 16, index, world);
particle.clip.onEnterFrame = mx.utils.Delegate.create(this, update);
particle.clip.onPress = mx.utils.Delegate.create(this, click);
}
function play(state) {
if (state) {
particle.clip._alpha = 100;
}
}
function turnOn() {
particle.scale = 3;
particle.render();
}
function turnOff() {
particle.scale = 0.3;
particle.render();
}
function update() {
particle.rotateX(((10 * (Stage.width - _root._xmouse)) / Stage.width) - 5);
particle.rotateY(((10 * (Stage.height - _root._ymouse)) / Stage.height) - 5);
particle.render();
if (particle.clip._alpha > 50) {
particle.clip._alpha--;
}
}
}
Symbol 20490 MovieClip [__Packages.net.pluginmedia.particles.Emitter3D] Frame 0
class net.pluginmedia.particles.Emitter3D
{
var x, y, z, active;
function Emitter3D (x, y, z) {
this.x = x;
this.y = y;
this.z = z;
active = false;
}
}
Symbol 20491 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.DrumMachineUI] Frame 0
class org.flashcodersbrighton.drummachine.dmf.DrumMachineUI extends org.flashcodersbrighton.drummachine.dmf.EventBroadcaster
{
var model, tracks, rootclip, trackviewfactory, dispatchEvent, slider, track;
function DrumMachineUI (model, rootclip, trackviewfactory) {
super();
this.model = model;
tracks = model.tracks;
this.rootclip = rootclip;
this.trackviewfactory = trackviewfactory;
model.addEventListener("newState", mx.utils.Delegate.create(this, refresh));
model.addEventListener("changeState", mx.utils.Delegate.create(this, updateStateView));
model.clock.addEventListener("tick", mx.utils.Delegate.create(this, randomplay));
var _local6 = new org.flashcodersbrighton.drummachine.dmf.AppController(model, this);
createUI();
createTrackUIs();
}
function refresh() {
var _local2 = 0;
for ( ; _local2 < trackUIs.length ; _local2++) {
trackUIs[_local2].refresh();
}
updateStateView();
}
function updateStateView(event) {
rootclip.state.text = model.getStates().join(sep);
}
function createTrackUIs(event) {
updateStateView(event);
var _local3 = 0;
for ( ; _local3 < tracks.length ; _local3++) {
trackUIs.push(new org.flashcodersbrighton.drummachine.dmf.TrackUI(tracks[_local3], trackviewfactory));
}
}
function getStates() {
return(rootclip.state.text.split(sep));
}
function setStates(states) {
org.flashdevelop.utils.FlashConnect.mtrace("fff" + states, "org.flashcodersbrighton.drummachine.dmf.DrumMachineUI::setStates", "C:\\Documents and Settings\\arthur\\Desktop\\drumsvn\\DMF\\classes/org/flashcodersbrighton/drummachine/dmf/DrumMachineUI.as", 68);
rootclip.state.text = states.join(sep);
}
function onKeyDown() {
if (Key.isDown(Key.ENTER)) {
newState();
}
var _local2 = chr(Key.getAscii());
org.flashdevelop.utils.FlashConnect.mtrace(_local2, "org.flashcodersbrighton.drummachine.dmf.DrumMachineUI::onKeyDown", "C:\\Documents and Settings\\arthur\\Desktop\\drumsvn\\DMF\\classes/org/flashcodersbrighton/drummachine/dmf/DrumMachineUI.as", 76);
if ((_local2 == "r") || (_local2 == "R")) {
var _local3 = getTimer();
randomize(false);
(org.flashdevelop.utils.FlashConnect.mtrace((getTimer() - _local3) + "ms", "org.flashcodersbrighton.drummachine.dmf.DrumMachineUI::onKeyDown", "C:\\Documents and Settings\\arthur\\Desktop\\drumsvn\\DMF\\classes/org/flashcodersbrighton/drummachine/dmf/DrumMachineUI.as", 81));// not popped
}
if ((_local2 == "l") || (_local2 == "L")) {
model.setStates([0, 0, 0, 0, 0, 0], false);
}
if ((_local2 == "p") || (_local2 == "P")) {
randomplayon = !randomplayon;
randomize();
}
}
function randomplay() {
if ((((counter++) % 16) == 0) && (randomplayon)) {
randomize();
}
}
function randomize() {
setStates(getRandomLine());
newState();
}
function newState() {
dispatchEvent({type:"newState", target:this});
}
function getBPM() {
return(slider.value());
}
function sliderChanged() {
dispatchEvent({type:"newBPM", target:this});
}
function createUI() {
slider = new org.flashcodersbrighton.drummachine.dmf.SliderView(model.bpm);
slider.addEventListener("change", mx.utils.Delegate.create(this, sliderChanged));
Key.addListener(this);
}
function getRandomLine() {
var _local2 = [0, 0, 0, 0, 0, 0];
if (track == null) {
track = Math.floor((Math.random() * _local2.length) - 0.01);
}
var _local3 = 0;
for ( ; _local3 < 16 ; _local3++) {
var _local4 = Math.pow(2, _local3);
_local2[track] = _local2[track] + _local4;
var _local5 = Math.random();
var _local6 = 0;
if (_local5 < 0.33) {
_local6 = 1;
}
if (_local5 > 0.66) {
_local6 = -1;
}
for ( ; track == (_local2.length - 1) ; _local3++) {
track = _local2.length - 2;
}
for ( ; track == 0 ; _local3++) {
track = 1;
}
track = track + _local6;
}
org.flashdevelop.utils.FlashConnect.mtrace(_local2, "org.flashcodersbrighton.drummachine.dmf.DrumMachineUI::getRandomLine", "C:\\Documents and Settings\\arthur\\Desktop\\drumsvn\\DMF\\classes/org/flashcodersbrighton/drummachine/dmf/DrumMachineUI.as", 157);
return(_local2);
}
var trackUIs = [];
var sep = "-";
var counter = 0;
var randomplayon = false;
}
Symbol 20492 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.AppController] Frame 0
class org.flashcodersbrighton.drummachine.dmf.AppController
{
var model, view;
function AppController (model, view) {
this.model = model;
this.view = view;
view.addEventListener("newState", mx.utils.Delegate.create(this, change));
view.addEventListener("newBPM", mx.utils.Delegate.create(this, changeBPM));
}
function change(event) {
model.setStates(event.target.getStates());
}
function changeBPM(event) {
model.setBPM(event.target.getBPM());
}
}
Symbol 20493 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.SliderView] Frame 0
class org.flashcodersbrighton.drummachine.dmf.SliderView extends org.flashcodersbrighton.drummachine.dmf.EventBroadcaster
{
var handle, right, bottom, slidervalue, dispatchEvent;
function SliderView (startbpm) {
super();
handle = org.flashcodersbrighton.drummachine.dmf.TileFactory.getSquare(_root, 100, 18, 777);
right = Stage.width - handle._width;
bottom = (Stage.height - handle._height) - 400;
handle._x = Math.round(((startbpm - 40) * right) / 54);
handle._y = bottom;
handle.createTextField("tf", 555, 0, 0, 58, 14);
setupTF(handle.tf);
handle.onPress = mx.utils.Delegate.create(this, draghandle);
handle.onReleaseOutside = (handle.onRelease = function () {
this.stopDrag();
this._x = Math.round(this._x);
Mouse.removeListener(this);
});
newValue();
}
function draghandle() {
handle.startDrag(false, 0, bottom, right, bottom);
Mouse.addListener(this);
}
function value() {
return(slidervalue);
}
function newValue() {
slidervalue = Math.round(((handle._x * 54) / right) + 40);
handle.tf.text = (" " + slidervalue) + " bpm";
}
function onMouseMove() {
newValue();
dispatchEvent({type:"change", target:this});
}
function setupTF(tf) {
tf.border = true;
tf.background = true;
tf.backgroundColor = 26112;
var _local3 = new TextFormat();
_local3.font = "Font 1";
_local3.size = 8;
_local3.color = 65280;
tf.setNewTextFormat(_local3);
tf.embedFonts = true;
tf._x = 2;
tf._y = 2;
}
}
Symbol 20494 MovieClip [__Packages.net.pluginmedia.particles.World] Frame 0
class net.pluginmedia.particles.World
{
function World () {
}
var centreX = 0;
var centreY = 0;
var fov = 250;
var pCount = 0;
}
Symbol 20495 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.DrumMachineApp] Frame 0
class org.flashcodersbrighton.drummachine.dmf.DrumMachineApp
{
static var app;
var model, ui;
function DrumMachineApp (model, rootclip) {
this.model = model;
ui = new org.flashcodersbrighton.drummachine.dmf.DrumMachineUI(model, rootclip, new org.flashcodersbrighton.drummachine.dmf.TrackViewFactory(rootclip, model));
}
function setStates(states) {
model.setStates(states);
}
static function start(filenames, bpm, rootclip, states) {
var _local6 = new org.flashcodersbrighton.drummachine.dmf.DrumMachineModel(filenames, bpm);
app = new org.flashcodersbrighton.drummachine.dmf.DrumMachineApp(_local6, rootclip);
app.setStates(states);
}
}
Symbol 20496 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.View3D] Frame 0
class org.flashcodersbrighton.drummachine.dmf.View3D extends org.flashcodersbrighton.drummachine.dmf.BaseTrackView
{
var switches, emitters, particles, rootclip, particleCounter, world, trackindex, trackmodel;
function View3D () {
super();
}
function TrackView() {
}
function initialise() {
switches = [];
emitters = [];
particles = [];
rootclip.onEnterFrame = mx.utils.Delegate.create(this, updateParticles);
particleCounter = 0;
world = net.pluginmedia.particles.WorldFactory.getInstance(rootclip._parent);
}
function createPart(i) {
var _local3 = new net.pluginmedia.particles.Emitter3D((trackindex - 3) * -50, 0, 0);
emitters.push(_local3);
}
function turnOff(i) {
emitters[i].active = false;
}
function turnOn(i) {
emitters[i].active = true;
}
function play(event) {
var _local3 = emitters[event.target.part];
if (_local3.active) {
var _local4 = new net.pluginmedia.particles.Particle3D("ball", rootclip, _local3.x, _local3.y, _local3.z, particleCounter++, world);
_local4.setVel((trackindex - 3) * -1, (-trackmodel.clock.BPM) / 10, (-trackmodel.clock.BPM) / 20);
_local4.scale = 0.5;
_local4.drag = 0.99;
_local4.gravity = 0.2;
_local4.floor = 50;
particles.push(_local4);
}
}
function updateParticles() {
var _local3 = 5;
while (particles.length >= _local3) {
var _local2 = particles.shift();
_local2.destroy();
}
var _local4 = 0;
for ( ; _local4 < particles.length ; _local4++) {
var _local2 = particles[_local4];
_local2.update();
_local2.render();
}
}
function randRange(min, max) {
var _local4 = Math.floor(Math.random() * ((max - min) + 1)) + min;
return(_local4);
}
}
Symbol 20497 MovieClip [__Packages.net.pluginmedia.particles.WorldFactory] Frame 0
class net.pluginmedia.particles.WorldFactory
{
static var worlds;
function WorldFactory () {
}
static function getInstance(clip) {
if (worlds == null) {
worlds = new Object();
}
var _local3 = clip._target;
if (worlds[_local3] == null) {
worlds[_local3] = create();
}
return(worlds[_local3]);
}
static function create() {
return(new net.pluginmedia.particles.World());
}
}
Symbol 20498 MovieClip [__Packages.net.pluginmedia.particles.Particle3D] Frame 0
class net.pluginmedia.particles.Particle3D
{
var world, clip, x, y, z, scale, xVel, yVel, zVel, blurFilter, floor;
function Particle3D (clipname, targetclip, xpos, ypos, zpos, depth, world) {
this.world = world;
clip = targetclip.attachMovie(clipname, "particle" + (world.pCount++), depth);
x = xpos;
y = ypos;
z = zpos;
scale = 1;
xVel = 0;
yVel = 0;
zVel = 0;
blurFilter = new flash.filters.BlurFilter(0, 0, 1);
targetclip.filterArray = [blurFilter];
render();
}
function setVel(xvel, yvel, zvel) {
xVel = xvel;
yVel = yvel;
zVel = zvel;
}
function update() {
if (delay > 0) {
delay--;
} else {
x = x + xVel;
y = y + yVel;
z = z + zVel;
xVel = xVel * drag;
yVel = yVel * drag;
zVel = zVel * drag;
clip._alpha = clip._alpha + fade;
clip._xscale = (clip._yscale = clip._yscale * shrink);
var _local2 = 0.001;
yVel = ((Math.abs(yVel) < _local2) ? 0 : (yVel));
if ((floor != undefined) && (y > floor)) {
y = floor;
yVel = (-yVel) * 0.5;
} else {
yVel = yVel + gravity;
}
}
}
function render() {
var _local2 = world.fov / (world.fov + z);
clip._xscale = (clip._yscale = (_local2 * 100) * scale);
clip._x = world.centreX + (x * _local2);
clip._y = world.centreY + (y * _local2);
var _local3 = Math.round(10000 - (z * 2000));
while (clip._parent.getInstanceAtDepth(_local3)) {
_local3--;
}
clip.swapDepths(_local3);
if ((z < (-world.fov)) || (delay > 0)) {
clip._visible = false;
} else {
clip._visible = true;
}
}
function rotateY(value) {
var _local3 = Math.cos((value * Math.PI) / 180);
var _local4 = Math.sin((value * Math.PI) / 180);
var _local5 = x;
x = (_local5 * _local3) + (z * _local4);
z = (_local5 * (-_local4)) + (z * _local3);
_local5 = xVel;
xVel = (_local5 * _local3) + (zVel * _local4);
zVel = (_local5 * (-_local4)) + (zVel * _local3);
}
function rotateX(value) {
var _local3 = Math.cos((value * Math.PI) / 180);
var _local4 = Math.sin((value * Math.PI) / 180);
var _local5 = y;
y = (_local5 * _local3) + (z * _local4);
z = (_local5 * (-_local4)) + (z * _local3);
_local5 = xVel;
yVel = (_local5 * _local3) + (zVel * _local4);
zVel = (_local5 * (-_local4)) + (zVel * _local3);
}
function destroy() {
if (clip.getDepth() <= 0) {
var _local2 = 20000;
while (clip._parent.getInstanceAtDepth(_local2)) {
_local2++;
}
clip.swapDepths(_local2);
}
clip.removeMovieClip();
}
var drag = 1;
var fade = 0;
var shrink = 1;
var gravity = 0;
var delay = 0;
}
Symbol 20499 MovieClip [__Packages.org.flashdevelop.utils.FlashOut] Frame 0
class org.flashdevelop.utils.FlashOut
{
function FlashOut () {
}
static function trace(msg) {
fscommand ("trace", msg.toString());
}
}
Symbol 20500 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.TrackUI] Frame 0
class org.flashcodersbrighton.drummachine.dmf.TrackUI
{
var factory, views, controllers;
function TrackUI (trackmodel, factory) {
this.factory = factory;
views = factory.getViews(trackmodel);
var _local4 = 0;
for ( ; _local4 < views.length ; _local4++) {
controllers.push(new org.flashcodersbrighton.drummachine.dmf.TrackController(trackmodel, views[_local4]));
}
}
function refresh() {
var _local2 = 0;
for ( ; _local2 < views.length ; _local2++) {
views[_local2].refresh();
}
}
function destroy() {
var _local2 = 0;
for ( ; _local2 < views.length ; _local2++) {
views[_local2].destroy();
}
var _local3 = 0;
for ( ; _local3 < controllers.length ; _local3++) {
controllers[_local3].destroy();
}
factory.destroy();
}
}
Symbol 20501 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.DrumMachineModel] Frame 0
class org.flashcodersbrighton.drummachine.dmf.DrumMachineModel extends org.flashcodersbrighton.drummachine.dmf.EventBroadcaster
{
var tracks, bpm, filenames, clock, dispatchEvent;
function DrumMachineModel (filenames, bpm) {
super();
tracks = new Array();
this.bpm = bpm;
this.filenames = filenames;
clock = new org.flashcodersbrighton.drummachine.dmf.HiResTimer(bpm);
initialise();
}
function setBPM(value) {
clock.setBPM(value);
}
function initialise() {
tracks = new Array();
var _local2 = 0;
for ( ; _local2 < filenames.length ; _local2++) {
var _local3 = new org.flashcodersbrighton.drummachine.dmf.TrackModel(clock, filenames[_local2]);
_local3.addEventListener("changeState", mx.utils.Delegate.create(this, notifyStateChange));
tracks.push(_local3);
}
notifyNewState();
}
function notifyStateChange() {
dispatchEvent({type:"changeState", target:this});
}
function notifyNewState() {
dispatchEvent({type:"newState", target:this});
}
function getStates() {
var _local2 = [];
var _local3 = 0;
for ( ; _local3 < tracks.length ; _local3++) {
_local2.push(tracks[_local3].state);
}
return(_local2);
}
function setStates(states) {
var _local3 = 0;
for ( ; _local3 < tracks.length ; _local3++) {
tracks[_local3].state = _global.parseInt(states[_local3]);
}
notifyNewState();
}
var sep = "-";
}
Symbol 20502 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.TrackViewFactory] Frame 0
class org.flashcodersbrighton.drummachine.dmf.TrackViewFactory
{
var rootclip, ttracknum, clips;
function TrackViewFactory (rootclip) {
this.rootclip = rootclip;
ttracknum = 0;
clips = [];
while ((viewcount--) > 0) {
clips.push(rootclip.createEmptyMovieClip("view" + viewcount, viewcount));
}
clips[0]._x = 350;
clips[0]._y = 350;
clips[1]._y = 350;
clips[1]._x = 350;
}
function createViews() {
var _local2 = [];
_local2.push(new org.flashcodersbrighton.drummachine.dmf.View3D());
_local2.push(new org.flashcodersbrighton.drummachine.dmf.PartsView3D());
_local2.push(new org.flashcodersbrighton.drummachine.dmf.PartsView());
_local2.push(new org.flashcodersbrighton.drummachine.dmf.TrackView());
return(_local2);
}
function getViews(trackmodel) {
var _local3 = createViews();
startViews(_local3, trackmodel);
ttracknum++;
return(_local3);
}
function startViews(views, trackmodel) {
var _local4 = 0;
for ( ; _local4 < views.length ; _local4++) {
startView(trackmodel, clips[_local4], views[_local4]);
}
}
function startView(trackmodel, clip, view) {
var _local5 = clip.createEmptyMovieClip("view" + ttracknum, ttracknum);
view.init(trackmodel, _local5, ttracknum);
}
function destroy() {
ttracknum = 0;
}
var viewcount = 4;
}
Symbol 20503 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.TrackController] Frame 0
class org.flashcodersbrighton.drummachine.dmf.TrackController
{
var model, view, toggler;
function TrackController (model, view) {
this.model = model;
this.view = view;
toggler = mx.utils.Delegate.create(this, togglePart);
view.addEventListener("changeState", mx.utils.Delegate.create(this, toggler));
}
function togglePart(evt) {
model.hit(evt.i);
}
function destroy(evt) {
view.removeEventListener("changeState", toggler);
}
}
Symbol 20504 MovieClip [__Packages.mx.utils.Delegate] Frame 0
class mx.utils.Delegate extends Object
{
var func;
function Delegate (f) {
super();
func = f;
}
static function create(obj, func) {
var _local4 = function () {
var _local2 = arguments.callee.target;
var _local3 = arguments.callee.func;
return(_local3.apply(_local2, arguments));
};
_local4.target = obj;
_local4.func = func;
return(_local4);
}
function createDelegate(obj) {
return(create(obj, func));
}
}
Symbol 20505 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.PartView] Frame 0
class org.flashcodersbrighton.drummachine.dmf.PartView extends org.flashcodersbrighton.drummachine.dmf.BasePartView implements org.flashcodersbrighton.drummachine.dmf.IPartView
{
var square, rootclip, index, trackindex, click;
function PartView () {
super();
}
function create() {
square = org.flashcodersbrighton.drummachine.dmf.TileFactory.getSquare(rootclip, 10, 10, index);
square._x = 123 + (11 * index);
square._y = 39 + (11 * trackindex);
square.onPress = mx.utils.Delegate.create(this, click);
}
function play(state) {
}
function turnOn() {
square._alpha = 100;
}
function turnOff() {
square._alpha = 50;
}
function destroy() {
}
}
Symbol 20506 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.TrackView] Frame 0
class org.flashcodersbrighton.drummachine.dmf.TrackView extends org.flashcodersbrighton.drummachine.dmf.BaseTrackView
{
var switches, rootclip, trackindex, partToggled, trackmodel;
function TrackView () {
super();
}
function initialise() {
switches = [];
}
function createPart(i) {
var _local3 = org.flashcodersbrighton.drummachine.dmf.TileFactory.getTile(rootclip, i);
_local3.oy = (20 + (trackindex * 4)) + extraY(i);
_local3._y = -100;
_local3._x = (300 + (i * 8)) + extraX();
switches.push(_local3);
_local3.p.hitter.hit = mx.utils.Delegate.create(this, hit);
_local3.p.hitter.i = i;
_local3.slide = mx.utils.Delegate.create(this, slide);
_local3.p.hitter.onRelease = function () {
this.hit(this);
};
}
function extraX() {
return(64 + (-(trackindex * 8)));
}
function extraY(i) {
return(i * 4);
}
function hit(clip) {
delete clip.onEnterFrame;
partToggled(clip.i);
}
function slide(clip) {
var _local3 = clip.oy - clip._y;
if (_local3 < 1) {
clip._y = clip.oy;
delete clip.onEnterFrame;
} else {
clip._y = clip._y + (_local3 / 8);
}
}
function turnOff(i) {
var _local3 = switches[i];
_local3._y = _local3.oy;
}
function turnOn(i) {
var _local3 = switches[i];
_local3._y = _local3.oy - 7;
delete _local3.onEnterFrame;
}
function play(event) {
var _local3 = switches[event.target.part];
if (!trackmodel.isPlaying(event.target.part)) {
_local3._y = _local3._y - 3;
_local3.onEnterFrame = function () {
this.slide(this);
};
}
}
}
Symbol 20507 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.TileFactory] Frame 0
class org.flashcodersbrighton.drummachine.dmf.TileFactory
{
function TileFactory () {
}
static function getTile(parent, depth) {
var _local4 = parent.createEmptyMovieClip("x" + depth, depth++);
_local4.attachMovie("Pixel", "p", 333);
_local4.cacheAsBitmap = true;
_local4._xscale = (_local4._yscale = 25);
return(_local4);
}
static function getSquare(parent, w, h, d) {
var _local6 = parent.createEmptyMovieClip("x" + d, d++);
var _local7 = w;
var _local8 = h;
var _local9 = 65280;
_local6.clear();
_local6.beginFill(_local9, 100);
_local6.moveTo(0, 0);
_local6.lineTo(_local7, 0);
_local6.lineTo(_local7, _local8);
_local6.lineTo(0, _local8);
_local6.lineTo(0, 0);
_local6.endFill();
return(_local6);
}
static var depth = 0;
}
Symbol 20508 MovieClip [__Packages.org.flashdevelop.utils.FlashConnect] Frame 0
class org.flashdevelop.utils.FlashConnect
{
static var messages, socket, interval, swfUrl;
function FlashConnect () {
}
static function initialize() {
messages = new Array();
socket = new XMLSocket();
socket.onData = function (data) {
org.flashdevelop.utils.FlashConnect.status = 1;
org.flashdevelop.utils.FlashConnect.onReturnData();
};
socket.onConnect = function (success) {
if (success) {
org.flashdevelop.utils.FlashConnect.status = 1;
} else {
org.flashdevelop.utils.FlashConnect.status = -1;
}
org.flashdevelop.utils.FlashConnect.onConnection();
};
interval = _global.setInterval(sendStack, 50);
socket.connect(host, port);
}
static function sendStack() {
if ((messages.length > 0) && (status == 1)) {
var _local2 = new XML();
var _local3 = _local2.createElement("flashconnect");
while (messages.length != 0) {
var _local4 = XMLNode(messages.shift());
_local3.appendChild(_local4);
}
_local2.appendChild(_local3);
socket.send(_local2);
}
}
static function send(message) {
if (messages == null) {
initialize();
}
messages.push(message);
}
static function mtrace(msg, method, path, line) {
if (path.indexOf(":") < 0) {
if (swfUrl == undefined) {
var _local6 = _global.unescape(_level0._url).split("///");
if (_local6[0] == "file:") {
swfUrl = _local6[1];
swfUrl = swfUrl.substr(0, swfUrl.lastIndexOf("/") + 1).split("|").join(":");
} else {
swfUrl = "";
}
}
path = swfUrl + path;
}
var _local7 = (((path + ":") + line) + ":") + msg;
trace(_local7, DEBUG);
}
static function trace(msg, state) {
if (_global.isNaN(state)) {
state = DEBUG;
}
var _local4 = new XMLNode(1, null);
var _local5 = new XMLNode(3, _global.escape(msg));
_local4.attributes.state = state;
_local4.attributes.cmd = "trace";
_local4.nodeName = "message";
_local4.appendChild(_local5);
send(_local4);
}
static var status = 0;
static var host = "localhost";
static var port = 6969;
static var INFO = 0;
static var DEBUG = 1;
static var WARNING = 2;
static var ERROR = 3;
static var FATAL = 4;
}
Symbol 20509 MovieClip [__Packages.org.flashcodersbrighton.drummachine.dmf.TrackModel] Frame 0
class org.flashcodersbrighton.drummachine.dmf.TrackModel extends org.flashcodersbrighton.drummachine.dmf.EventBroadcaster
{
var filename, sound, state, clock, dispatchEvent;
function TrackModel (clock, filename) {
super();
this.filename = filename;
sound = new Sound();
state = 0;
sound.loadSound("mp3/" + filename, false);
this.clock = clock;
sound.onSoundComplete = mx.utils.Delegate.create(this, soundEnd);
clock.addEventListener("tick", mx.utils.Delegate.create(this, playNext));
}
function hit(i) {
var _local3 = Math.pow(2, i);
var _local4 = (isOn(_local3) ? -1 : 1);
state = state + (_local3 * _local4);
dispatchEvent({target:this, type:"changeState", i:i});
}
function isPlaying(pos) {
return(isOn(Math.pow(2, pos)));
}
function playNext(event) {
var _local3 = Math.pow(2, (part + 2) % 16);
event.target = this;
var _local4 = {};
_local4.event = event;
dispatchEvent(event);
if (isOn(_local3) && (soundsplaying < 30)) {
sound.start(0.67 - event.offset);
soundsplaying++;
}
part = (++part) % PARTS;
}
function tick(timer) {
_global.clearInterval(timer.id);
dispatchEvent(timer.event);
}
function isOn(val) {
return((state & val) != 0);
}
function soundEnd() {
soundsplaying--;
}
var part = 0;
var PARTS = 16;
static var soundsplaying = 0;
}
Symbol 20510 MovieClip [__Packages.Main] Frame 0
class Main
{
function Main () {
}
static function main() {
org.flashcodersbrighton.drummachine.dmf.DrumMachineApp.start(["chime6.mp3", "chime5.mp3", "chime4.mp3", "chime3.mp3", "chime2.mp3", "chime1.mp3"], 60, _root, [0, 0, 0, 0, 0, 0]);
}
//ASSetPropFlags(_local1, null, 1);
}