PowerfulWebsites
09-02-2006, 04:58 AM
I'm trying to set up an addEventListener to a sound object inside a method in a custom component.
I am able to set it up with a simple callback, but I need to be able to generate an eventObject.
This works: (I'm generating my sound object name dynamically)
// This works but does not dispatch an eventObject
this[var_tempSoundObjName] = new Sound(this);
this[var_tempSoundObjName].attachSound(this.pSoundReference);
this[var_tempSoundObjName].start();
this[var_tempSoundObjName].onSoundComplete = Delegate.create(this, onSoundFinished);
This does not work (nor do any other of the many combinations I have tried):
var sound = new Sound(this);
sound.attachSound(this.pSoundReference);
sound.start();
var myListener = new Object();
myListener.onSoundComplete = function(evt:Object):Void{
trace("end of sound");
}
sound.addEventListener("onSoundComplete", myListener);
All I'm trying to do is set up a onSoundComplete callback that passes an eventObject to a function.
Any help is greatly appreciated.
I am able to set it up with a simple callback, but I need to be able to generate an eventObject.
This works: (I'm generating my sound object name dynamically)
// This works but does not dispatch an eventObject
this[var_tempSoundObjName] = new Sound(this);
this[var_tempSoundObjName].attachSound(this.pSoundReference);
this[var_tempSoundObjName].start();
this[var_tempSoundObjName].onSoundComplete = Delegate.create(this, onSoundFinished);
This does not work (nor do any other of the many combinations I have tried):
var sound = new Sound(this);
sound.attachSound(this.pSoundReference);
sound.start();
var myListener = new Object();
myListener.onSoundComplete = function(evt:Object):Void{
trace("end of sound");
}
sound.addEventListener("onSoundComplete", myListener);
All I'm trying to do is set up a onSoundComplete callback that passes an eventObject to a function.
Any help is greatly appreciated.