hi guys…i’m creating this metronome thing that gives tempo…i’ve got the metronome stick (an MC) to rotate and sound like how a metronome should but umm i cant get it to stop (i’ve a stop button to control this)
anyone hv any idea wat i shld do, i’m not very good at writing actionscripts and these codes are done with help from a fren…
here’s the codes on the stick MC
[AS]onClipEvent (load) {
tick = new Sound();
tick.attachSound (“ting”);
//max 60 deg to left/right
this.limitAngle = 40;
this.timer = new Date();
init();
function init() {
this.bpm = _root.beatsPerMin;
//start at -60 deg. to the left
this._rotation =-1this.limitAngle;
//beats per second
this.beatsPerSec = this.bpm/60;
//secPerBeat
this.secPerBeat = 1/this.beatsPerSec;
//how big an angle to move per millisec
this.anglePerMilliSec = this.limitAngle2this.beatsPerSec/1000;
//get the current millisec
this.TimeCheck = this.timer.getTime();
this.TimeSinceLastBeat = this.timer.getTime();
//initial direction of movement to the right
this.direction = 1;
}
}
onClipEvent (enterFrame) {
this.timer = new Date();
this.timePassed = this.timer.getTime()-this.TimeCheck;
this.TimeCheck = this.timer.getTime();this._rotation = this._rotation+(this.directionthis.timePassed*this.anglePerMilliSec);
//trace("time since last beat: " + (this.timer.getTime() - this.TimeSinceLastBeat));
//trace("millisec Per beat: " + (this.secPerBeat * 1000));
if (this.timer.getTime() - this.TimeSinceLastBeat >= this.secPerBeat * 1000 ) {this.TimeSinceLastBeat = this.timer.getTime();
//change direction of movement
this.direction = -1;
if(direction == 1){
tick.start();
this._rotation = -1this.limitAngle;
}
else{
tick.start();
this._rotation = this.limitAngle;
}
}
}
onClipEvent (load) {
stopRotate();
function stopRotate() {
this.bpm = _root.beatsPerMin;
this._rotation = false;
}
}[/AS]
then on the stop button, i’ve this codes
[AS]on (press) {_root.metronome.stopRotate();}[/AS]
thx