I am trying to create a juke box. I have created an instance (instance name is “thebeat”) with three frames. Each frame has a different music playing; the third frame is used to mute the music. I have also included a text movie animation in each frame to display the current music playing or to show the “mute” status on the third frame.
Frame 1:
Africanbeat.stop();
Africanbeat = new Sound(this);
Africanbeat.attachSound("afrobeat");
Africanbeat.start(0, 9999);
Africanbeat.setVolume(30);
stop();
Frame 2:
Africanbeat.stop();
Africanbeat = new Sound(this);
Africanbeat.attachSound("Coolbeat");
Africanbeat.start(0, 9999);
Africanbeat.setVolume(30);
stop();
Frame 3:
Africanbeat.stop();
I have also created a Volume slider to control the volume of the created “Africanbeat”. In addition, I have created a display for the volume level with the instance “musictext”. I used the code below for the slider.
onClipEvent (load) {
drag._y += 50;
}
onClipEvent (enterFrame) {
Vol = drag._y+50;
_parent._parent.thebeat.africanbeat.setvolume(vol);
_parent.musictext.volAt = Math.round(vol);
if (_parent.musictext.volAt<1 && _parent._parent.thebeat._currentFrame<3) {
_parent._parent.thebeat.gotoAndPlay(3);
_parent._parent.mainmusic_btn.gotoAndStop(2);
} else if (_parent.musictext.volAt>0 && _parent._parent.thebeat._currentFrame>2) {
_parent._parent.thebeat.prevFrame();
_parent._parent.mainmusic_btn.gotoAndStop(1);
}
}
In addition, I created a button to move between frame 1 and 2 on the “thebeat” instance. i.e to move between each music playing. Here’s the code below.
on (release, releaseOutside) {
if (thebeat._currentFrame == 1) {
thebeat.gotoAndStop(2);
} else if (thebeat._currentFrame == 2) {
thebeat.gotoAndStop(1);
} else if (thebeat._currentFrame == 3) {
thebeat.gotoAndStop(1);
}
}
Lastly, I created a mute button to directly control the vol slider. Here’s the code below.
on (release, releaseOutside) {
mute = _parent.soundctrl.volslider.drag._y+50
mutevol = Math.round(mute);
if (mutevol > 0) {
_parent.soundctrl.volslider.drag._y = -50
this.gotoAndStop(2);
}else if (mutevol < 1) {
_parent.soundctrl.volslider.drag._y = 50
this.gotoAndStop(1);
}
}
Here’s the problem. When I tested the jukebox, All functions work properly until I completely drag the volume slider down to zero or hit the mute volume. When I raise the volume slider or “unmute” the volume, the instance “thebeat” will always return to the music playing on frame 2 instead of the music playing on either frame 1 or 2 before the volume was zero. Therefore, if the music on frame 1 of “thebeat” was playing and the mute button is pressed or volume slider dragged to zero, “thebeat” instance will always return to frame 2 instead of the previous frame that was where the music was playing before muting “africanbeat” on frame 3. I hope u understand the this. I believe the problem lies with the “prevFrame();” code used on the slider. Is there another string of code I can use to serve this function.
Basically, what I want is to be able to return to the previous frame on “thebeat” every time I raise the volume from mute status (i.e. frame3) i.e. whenever -->“else if (_parent.musictext.volAt>0 && _parent._parent.thebeat._currentFrame>2) {” --> go to the previous frame on “thebeat.”
sorry for the long post. Pls help. Thanks