Skip to main content
Inspiring
October 3, 2007
Question

Please help; next btn and onSoundComplete()

  • October 3, 2007
  • 2 replies
  • 263 views
Hi,

Can someone help me form tearing out any more hair? The following code should work but it is not, it should play the next song:

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]);
};

I have it also attached to a Next button, as follows;

next_btn.onRelease = function(){
(song_nr == songfile.length+1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};

The XML code is as follows;

?xml version='1.0' encoding='utf-8'?>
<songs>
<song name="i-tuts" file="ituts_track.mp3" ><song />
<song name="test2" file="test2.mp3" ><song />
</songs>

Any help, will greatly reduce hair loss ;)

Boxing Boom
This topic has been closed for replies.

2 replies

clbeech
Inspiring
October 3, 2007
Hey BB, could you repost that code using the 'Attach Code' button, clock on the 'reply' link at the top of the message window.
clbeech
Inspiring
October 3, 2007
well I can't be sure not knowing the rest of the document's structure, but it looks like you have some scope problems here.

1) remove the 'this' keyword from onSoundComplete, if the 'sound_obj' is local to the frame it shouldn't be needed.

2) I noticed you have a '_global' reference to the 'song_nr' var, yet you are not using the _global within the the conditional expressions.

3) just wondering if the arrays 'songfile' and 'songname' are within the same scope as this frame, they would need to be, or have a reference to their locations.
Inspiring
October 3, 2007
Hi,

This is all of the code: Please help! I am a little rusty on my ActionScript.


I thank you.

Kind Regards,


Boxing Boom