I wrote this way too redundant code and I know there's a better way this can be done. I'd appreciate if anyone could help me out here.
Thanks.
Code:
_root.sTitle = 1;
_parent.createEmptyMovieClip("soundHolder_mc", 2);
s1 = new Sound(soundHolder_mc);
s1.loadSound("assets/music/1.mp3");
s2 = new Sound(soundHolder_mc);
s2.loadSound("assets/music/2.mp3");
s3 = new Sound(soundHolder_mc);
s3.loadSound("assets/music/3.mp3");
s4 = new Sound(soundHolder_mc);
s4.loadSound("assets/music/4.mp3");
s5 = new Sound(soundHolder_mc);
s5.loadSound("assets/music/5.mp3");
s6 = new Sound(soundHolder_mc);
s6.loadSound("assets/music/6.mp3");
s7 = new Sound(soundHolder_mc);
s7.loadSound("assets/music/7.mp3");
s8 = new Sound(soundHolder_mc);
s8.loadSound("assets/music/8.mp3");
s9 = new Sound(soundHolder_mc);
s9.loadSound("assets/music/9.mp3");
s10 = new Sound(soundHolder_mc);
s10.loadSound("assets/music/10.mp3");
/*this.onLoad = function() {
for (i = 1; i<11; i++) {
bt[i].onRollOver = function() {
s[i].start();
}
bt[i].onRollOut = function() {
s[i].stop();
}
bt[i].onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt[i].onRelease = function() {
_root.sTitle = [i];
this.stopDrag();
this._x = startx;
this._y = starty;
}
trace(i);
}
}*/
bt1.onRollOver = function() {
s1.start();
}
bt1.onRollOut = function() {
s1.stop();
}
bt1.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt1.onRelease = function() {
_root.sTitle = 1;
this.stopDrag();
this._x = startx;
this._y = starty;
}
bt2.onRollOver = function() {
s2.start();
}
bt2.onRollOut = function() {
s2.stop();
}
bt2.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt2.onRelease = function() {
_root.sTitle = 2;
this.stopDrag();
this._x = startx;
this._y = starty;
}
bt3.onRollOver = function() {
s3.start();
}
bt3.onRollOut = function() {
s3.stop();
}
bt3.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt3.onRelease = function() {
_root.sTitle = 3;
this.stopDrag();
this._x = startx;
this._y = starty;
}
bt4.onRollOver = function() {
s4.start();
}
bt4.onRollOut = function() {
s4.stop();
}
bt4.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt4.onRelease = function() {
_root.sTitle = 4;
this.stopDrag();
this._x = startx;
this._y = starty;
}
bt5.onRollOver = function() {
s5.start();
}
bt5.onRollOut = function() {
s5.stop();
}
bt5.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt5.onRelease = function() {
_root.sTitle = 5;
this.stopDrag();
this._x = startx;
this._y = starty;
}
bt6.onRollOver = function() {
s6.start();
}
bt6.onRollOut = function() {
s6.stop();
}
bt6.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt6.onRelease = function() {
_root.sTitle = 6;
this.stopDrag();
this._x = startx;
this._y = starty;
}
bt7.onRollOver = function() {
s7.start();
}
bt7.onRollOut = function() {
s7.stop();
}
bt7.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt7.onRelease = function() {
_root.sTitle = 7;
this.stopDrag();
this._x = startx;
this._y = starty;
}
bt8.onRollOver = function() {
s8.start();
}
bt8.onRollOut = function() {
s8.stop();
}
bt8.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt8.onRelease = function() {
_root.sTitle = 8;
this.stopDrag();
this._x = startx;
this._y = starty;
}
bt9.onRollOver = function() {
s9.start();
}
bt9.onRollOut = function() {
s9.stop();
}
bt9.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt9.onRelease = function() {
_root.sTitle = 9;
this.stopDrag();
this._x = startx;
this._y = starty;
}
bt10.onRollOver = function() {
s10.start();
}
bt10.onRollOut = function() {
s10.stop();
}
bt10.onPress = function() {
this.startDrag();
startx = this._x;
starty = this._y;
}
bt10.onRelease = function() {
_root.sTitle = 10;
this.stopDrag();
this._x = startx;
this._y = starty;
}
submitSound.onPress = function() {
if (sTitle == 1) {
s1.start();
} else if (sTitle == 2) {
s2.start();
} else if (sTitle == 3) {
s3.start();
} else if (sTitle == 4) {
s4.start();
} else if (sTitle == 5) {
s5.start();
} else if (sTitle == 6) {
s6.start();
} else if (sTitle == 7) {
s7.start();
} else if (sTitle == 8) {
s8.start();
} else if (sTitle == 9) {
s9.start();
} else if (sTitle == 10) {
s10.start();
}
}