I have created a XML player from a tutorial online. I can’t remember where I got it from though. So I can’t ask the creator these questions.
The player has ‘stop, play, fwd, rwd’ buttons. They all work fine.
The problem is the AS that came along with the player’s tut.
First it has been set to Random Play.
I want to select a certain track to start playing first.
Plus when any track finishes, it shows that the next track has loaded. But it doesn’t start playing. You have to actually click the ‘play’ button for it to start playing the next song.
I’m definitely not the greatest when it come to AS.
So any help would be appreciated.
Here is the AS:
format = new TextFormat();
display_txt.bold = true;
display_txt.border = false;
display_txt.background = false;
display_txt.setTextFormat(format);
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* = playlist.firstChild.childNodes*.attributes.name;
_global.songfile* = playlist.firstChild.childNodes*.attributes.file;
trace(songname*+" "+songfile*);
}
}
_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]);
};
MovieClip.prototype.songStarter = function(file, name) {
this.sound_obj.loadSound(file, true);
this.onEnterFrame = function() {
if (this.sound_obj.position>0) {
delete this.onEnterFrame;
this._parent.display_txt.text = name;
} else {
this._parent.display_txt.text = “loading…”;
}
};
this.sound_obj.onSoundComplete = function() {
(song_nr == songfiles.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfiles[song_nr], songname[song_nr]);
};
};
btn_play.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
btn_stop.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
};
btn_next.onRelease = function() {
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
btn_prev.onRelease = function() {
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr–;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
playlist.load(“playlist.xml”);
Oh, and if it makes any difference. The AS and the MC is on the root of the Movie.
Thanks,
Deadcell