Anyway, my only issue with the player is the volume position - if you try dragging the volume to zero, it works perfectly, but if you then press next or back (or just wait for the next song to start) the volume shoots back up, rather than staying at zero. Here's my code (as I already explained, it's pretty complicated):
import com.mosesSupposes.fuse.*;
ZigoEngine.register(PennerEasing, Fuse);
FuseXML.OUTPUT_LEVEL = 2;
var myfxml:FuseXML = new FuseXML('mp3s/sbplaylist.xml');
myfxml.target = arm_mc;
stop();
_level0.player.btn_play._visible = false;
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songfile = [];
_global.songrotate = [];
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]);
}
}
_level0.player.createEmptyMovieClip("sound_mc", 1);
_global.song_nr = random(songfile.length);
_level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], song_nr);
};
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;
_level0.player.timeDisplay_txt.text = min+":"+sec;
}
MovieClip.prototype.songStarter = function(file, name, band, sn:Number) {
trace( sn );
myfxml.start('tween'+ Number(_global.song_nr+1), true);
if (_level0.player.sound_obj) {
_level0.player.sound_obj.stop();
delete _level0.player.sound_obj;
}
_level0.player.sound_obj = new Sound(this);
_level0.player.sound_obj.loadSound(file, true);
_level0.player.sound_obj.setVolume(50);
_level0.player.onEnterFrame = function() {
if (_level0.player.sound_obj.position>0) {
delete _level0.player.onEnterFrame;
_level0.player.display_txt.text = name+" / "+band;
timeInterval = setInterval(timer, 1000, _level0.player.sound_obj);
} else {
_level0.player.display_txt.text = "loading...";
}
};
_level0.player.sound_obj.onSoundComplete = function() {
clearInterval(timeInterval);
_level0.player.timeDisplay_txt.text = "00:00";
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], song_nr);
};
_level0.player.volume1.dragger.onPress = function() {
startDrag(this, true, 0, this._y, _level0.player.volume1.volBG._width, this._y);
_level0.player.onEnterFrame = function() {
var p = (_level0.player.volume1.dragger._x/_level0.player.volume1.volBG._width)*100;
_level0.player.sound_obj.setVolume(p);
};
};
_level0.player.volume1.dragger.onRelease = function() {
delete this.onEnterFrame;
stopDrag();
};
_level0.player.volume1.dragger.onReleaseOutside = function() {
stopDrag();
};
};
_level0.player.btn_play.onRelease = function() {
_level0.player.btn_play._visible = false;
_level0.player.btn_stop._visible = true;
// set this to maximum desired rate
_root.record.maxRate = 10;
// set this to control the initial acceleration
_root.record.accel = 0.5;
_root.record.curRate = 0;
_root.record.onEnterFrame=function()
{
if (this.curRate < this.maxRate)
{
this.curRate += this.accel;
}
this._rotation += this.curRate;
}
if (pause == true){ // no comment....
_level0.player.sound_obj.start(posiP) // start sound from the previously saved position
}
else {
clearInterval(timeInterval);
_level0.player.timeDisplay_txt.text = "00:00";
_level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], song_nr);
}
};
_level0.player.btn_stop.onRelease = function() {
_level0.player.btn_stop._visible = false;
_level0.player.btn_play._visible = true;
_root.record.maxRate = 0;
_root.record.accel = 0.5;
_root.record.curRate = 10;
_root.record.onEnterFrame=function()
{
if (this.curRate > this.maxRate)
{
this.curRate -= this.accel;
}
this._rotation += this.curRate;
}
_level0.player.sound_obj.stop(); //stop the current sound
posiP = _level0.player.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
}
_level0.player.btn_fw.onRelease = function() {
_root.record.maxRate = 10;
_root.record.accel = 0.5;
_root.record.curRate = 0;
_root.record.onEnterFrame=function()
{
if (this.curRate < this.maxRate)
{
this.curRate += this.accel;
}
this._rotation += this.curRate;
}
clearInterval(timeInterval);
_level0.player.timeDisplay_txt.text = "00:00";
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], song_nr);
};
_level0.player.btn_rev.onRelease = function() {
_root.record.maxRate = 10;
_root.record.accel = 0.5;
_root.record.curRate = 0;
_root.record.onEnterFrame=function()
{
if (this.curRate < this.maxRate)
{
this.curRate += this.accel;
}
this._rotation += this.curRate;
}
clearInterval(timeInterval);
_level0.player.timeDisplay_txt.text = "00:00";
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
_level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], song_nr);
};
_level0.player.back_btn.onRelease = function() {
stopAllSounds();
gotoAndStop("home");
}
playlist.load("mp3s/sbplaylist.xml");
_root.record.maxRate = 10;
_root.record.accel = 0.5;
_root.record.curRate = 0;
_root.record.onEnterFrame=function()
{
if (this.curRate < this.maxRate)
{
this.curRate += this.accel;
}
this._rotation += this.curRate;
}
I'm hoping someone will be nice enough to look through it and try to figure out why the volume isn't remembering it's position - I'm thinking it's something to do with the levels, maybe? Or a little bit of code is wrong? I'm pretty sure it'd be in here somewhere:
_level0.player.volume1.dragger.onPress = function() {
startDrongfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_level0.playag(this, true, 0, this._y, _level0.player.volume1.volBG._width, this._y);
_level0.player.onEnterFrame = function() {
var p = (_level0.player.volume1.dragger._x/_level0.player.volume1.volBG._width)*100;
_level0.player.sound_obj.setVolume(p);
};
};
_level0.player.volume1.dragger.onRelease = function() {
delete this.onEnterFrame;
stopDrag();
};
_level0.player.volume1.dragger.onReleaseOutside = function() {
stopDrag();
};
};
...but can't for the life of me figure out the problem. I should also mention that I've rotated the entire volume1 mc -90° , which doesn't seem to have affected the dragger (still works when you drag it), but may be part of the problem here.
It's very frustrating, because the record player works perfectly besides this issue, so I'm desperately hoping someone's kind enough to help out!
Cheers!
Boog
