thanks Pax, but it still didn't fix my problem.
With your code i end up having the same problem as before, the button won't mute anymore when i've used to volumeslider :-/
it sounds like its being overruled by something else :-/ i discovered that as soon as the volumeslider has been touched, the button doenst work anymore!
this is my code... any ideas?
stop();
var amountLoaded:Number;
var duration:Number;
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
//trace(songname[i]+" "+songfile[i]+" "+songband[i]);
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_root.sound_mc.sound_obj = new Sound();
_global.song_nr = random(songfile.length);
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[
song_nr]);
};
MovieClip.prototype.songStarter = function(file, name, band) {
this.sound_obj.loadSound(file, true);
this.onEnterFrame = function() {
if (this.sound_obj.position>0) {
delete this.onEnterFrame;
displaytags.display_txt.text = name;
displaytags.artist_txt.text = band;
} else {
displaytags.display_txt.text = "loading...";
displaytags.artist_txt.text = "loading...";
}
};
this.sound_obj.onSoundComplete = function() {
clearInterval(timeInterval);
timeDisplay_txt.text = "00:00/00:00";
(song_nr == songfiles.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfiles[song_nr], songname[song_nr], songband[
song_nr]);
};
volume1.dragger.onPress = function() {
startDrag(this, true, 0, this._y, this._parent.volBG._width - 7, this._y);
this.onEnterFrame = function() {
var p = (this._x/this._parent.volBG._width)*100;
_root.sound_mc.sound_obj.setVolume(p);
};
}
volume1.mute.onRelease = function() {
//startDrag(this, true, 0, this._y, this._parent.volBG._width , this._y);
this.onEnterFrame = function() {
//var p = (this._x/this._parent.volBG._width)*100;
_root.sound_mc.sound_obj.setVolume(0);
};
}
volume1.dragger.onRelease = function() {
delete this.onEnterFrame;
stopDrag();
};
volume1.dragger.onReleaseOutside = function() {
stopDrag();
};
function timer(sound_obj) {
time = sound_obj.position/1000;
min = Math.floor(time/60);
min = (min<10) ? "0"+min : min;
sec = Math.floor(time%60);
sec = (sec<10) ? "0"+sec : sec;
timeDisplay_txt.text = min+":"+sec+"/"+totalDuration;
}
function duration (){
timed = _root.sound_mc.sound_obj.duration/1000;
mind = Math.floor(timed/60);
mind = (mind<10) ? "0"+mind : mind;
secd = Math.floor(timed%60);
secd = (secd<10) ? "0"+secd : secd;
totalDuration = mind+":"+secd;
}
function soundStatus(){
var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded() / _root.sound_mc.sound_obj.getBytesTotal();
loader.loadBar._width = amountLoaded*181;
duration = _root.sound_mc.sound_obj.duration;
position = _root.sound_mc.sound_obj.position;
playHead._x = position / duration*193-5;
}
};
mute_.onRelease = function() {
if(!this.bMuted){
_root.sound_mc.sound_obj.setVolume(0);
this.bMuted = true;
} else {
_root.sound_mc.sound_obj.setVolume(100);
this.bMuted = false;
}
}
btn_play.onRelease = function() {
clearInterval(timeInterval);
if (pause == true){ // no comment....
_root.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position
}
else {
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
}
};
btn_pause.onRelease = function() { //pause button function
clearInterval(timeInterval);
_root.sound_mc.sound_obj.stop(); //stop the current sound
posiP = _root.sound_mc.sound_obj.position / 1000; // save the current position in a new variable and divide by 1000 (ms -> sec)
pause = true;//set the variable pause to true
}
btn_stop.onRelease = function() {
clearInterval(timeInterval);
_root.sound_mc.sound_obj.stop();
pause = false;
};
btn_fw.onRelease = function() {
clearInterval(timeInterval);
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[
song_nr]);
};
btn_rev.onRelease = function() {
clearInterval(timeInterval);
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[
song_nr]);
};
playlist.load("playlist.xml");
setInterval(duration, 100);
setInterval(soundStatus,100);
Edited by dlusion, 04 March 2007 - 03:46 PM.