Let's introduce my work :
I'm in a french independant power-pop band called Bubblies, we're about to release our new album on an USB key with MP3 songs, bonus and lot of things...
I'm working on an mp3 player (included on the USB key) based on Funkysoul tut.
I want to create two levels for navigation between songs : next & prev button on the player and one button for each songs (each button is different so I create them one by one - only 12)
I would like to implement, for each song, a graphical animation (external swf could be easier for future evolutions....).
For now, the external anim works when i Click on the direct button but is not linked with played song.
I would like to use AS and same xml file (playlist.xml) to load anim on click (next & prev) and each button... and when a new song begin, change it too...
I know the method will be similar to the sound part.... But i'm a action script noob and need some help.
I burnt some part of my brain making the songs playing in the chosen order after choosing one with individual song button...
Could someone please give me some direction to begin or some link ?
Here is th AS part :
------------------------------------------------------------------------------------------------------------------------------------------------------
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
trace(songname[i]+" "+songfile[i]);
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_root.sound_mc.sound_obj = new Sound();
_global.song_nr = 0;
_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 = "press play ...";
}
};
this.sound_obj.onSoundComplete = function() {
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
};
btn_play.onRelease = function() {
if (pause == true){ // no comment....
this._parent.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position
}
else {
clearInterval(timeInterval);
_root.timeDisplay_txt.text = "00:00/00:00";
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
}
};
btn_stop.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
pause = false;
};
btn_fw.onRelease = function() {
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
pause = false;
};
btn_rev.onRelease = function() {
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
pause = false;
};
btn_pause.onRelease = function() { //pause button function
this._parent.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
}
playlist.load("things/playlist.xml");
// Individual song buttons
btn_glitter.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[0], songname[0]);
_global.song_nr=0
};
btn_lamouche.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[1], songname[1]);
_global.song_nr=1
};
btn_space.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[2], songname[2]);
_global.song_nr=2};
btn_stone.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[3], songname[3]);
_global.song_nr=3};
btn_thehead.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[4], songname[4]);
_global.song_nr=4};
btn_icescream.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[5], songname[5]);
_global.song_nr=5};
btn_labelvie.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[6], songname[6]);
_global.song_nr=6};
btn_amiabird.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[7], songname[7]);
_global.song_nr=7};
btn_spirale.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[8], songname[8]);
_global.song_nr=8};
btn_miracle.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[9], songname[9]);
_global.song_nr=9};
btn_sucre.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[10], songname[10]);
_global.song_nr=10};
btn_memories.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[11], songname[11]);
_global.song_nr=11};
------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks !!
Plon.
ps : sorry for my approximative english....
