// clapping music, steve reich 1972 // written in ActionScript 1.0/Flash MX // may 2005, michael murtaugh, mm@automatist.org var repeatsperbar = 12; var curbar = 0, framecount = 0, totalbars = 13; var repeatscount = repeatsperbar; // force bar update on first onEnterFrame function oef () { cf = this._currentframe; pf = cf - 1; if (pf < 1) pf = this._totalframes; this.arcs[pf-1]._alpha = 50; this.arcs[cf-1]._alpha = 100; if (this._currentframe == this.startframe) { this.loopcount += 1; if (this.loopcount == repeatsperbar) { if (this.crawl) { // shift the pattern this.arcs[cf-1]._alpha = 50; this.startframe += 1; this._rotation -= 30; if (this.startframe > this._totalframes) this.startframe = 1; } this.loopcount = 0; this.gotoAndPlay(this.startframe); } } // stop at the end of the final bar if ((_root.curbar == _root.totalbars) && (this.loopcount >= repeatsperbar - 1) && (this._currentframe == this._totalframes)) this.stop(); } var pat = [1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0]; function initSymbols (mc, arcName) { mc.arcs = Array(); for (var i=0; i<12; i++) { var arc = mc.attachMovie(arcName, "arc" + i, i); mc.arcs.push(arc); arc._rotation = -105 + (i * 30); arc._alpha = 50; arc._visible = _root.pat[i] ==1; } } function init(mc) { mc.onEnterFrame = oef; mc.loopcount = 0; mc.startframe = 1; } init(audio1); init(audio2); audio2.crawl = true; initSymbols(audio1, "arc100"); initSymbols(audio2, "arc83"); function onEnterFrame() { if (curbar > 13) return; framecount += 1; if (framecount == audio1._totalframes) { repeatscount += 1; framecount = 0; } if (repeatscount == repeatsperbar) { curbar += 1; repeatscount = 0; if (curbar <= 13) { label.text = "bar " + curbar; } else { label.text = ""; } } } stop();