Class scope / event handler issues

note: code below

this is a class i wrote to handle mp3 streaming player controls… all works good except the onSongComplete / execute_song_change functionality. I am noticing that when my mp3 class routine for execute_song_change is attached to the onSongComplete event handler, the rest of the class functionality (eg: execute_*) is out of the scope chain. I have code below and comments on the section that is giving me problems.

I have tried using _parent, to be able to get access to the calling functions scope, but that did not work. If anyone can see any problems with the below code, please let me know. Much appriciated.

-ralph
[AS]

// construction for Mp3Player Object / Class
function Mp3Player ()
{
this.playlist_array = new Array();
this.mp3player_sound = new Sound();
this.mp3player_sound.onSoundComplete = this.execute_song_change;
ASBroadcaster.initialize(this);
this.current_playlist_item = 0;
}

Mp3Player.prototype.start = function ()
{
this.execute_play();
}

Mp3Player.prototype.execute_song_change = function ()
{
trace(“Changing songs”); // this shows up in output
trace(execute_next); // this says ‘undefined’
execute_next(); // nothing happens
}

Mp3Player.prototype.execute_play = function ()
{
this.mp3player_sound.stop();
this.mp3player_sound.loadSound(this.playlist_array[this.current_playlist_item], true);
this.mp3player_sound.start();
}

Mp3Player.prototype.execute_stop = function ()
{
this.mp3player_sound.stop();
}

Mp3Player.prototype.execute_next = function ()
{
( (this.current_playlist_item+1) > (this.playlist_array.length-1) ) ? this.current_playlist_item = 0 : this.current_playlist_item++;
trace(this.current_playlist_item);
this.execute_play();
}

… more class stuf …
– snip snip --[/AS]