Hi Javier, This is because you've got things happening in the wrong order: - You create your EventTry() object, which calls init() - Init fires the event, but onEvent is still undefined - Init then calls die() - Die() deletes the EventTry object - You then set onEvent to your function - after everything else has already happened.
You need to set the onEvent object _before_ you fire the event to have anything meaningful happen. I can't understand how your old classes would have worked, looking at this code. Perhaps you're doing something slightly differently now? Hope that helps, Ian On 11/13/05, Javier Tello <[EMAIL PROTECTED]> wrote: > > Hello, I'm having troubles implementing the EventDispatcher class with > flash8. > > I do the same I use to do before, but now the class doesn't fired the > event. Here is a sample class: > ___ > > import mx.events.EventDispatcher; > // > class EventTry { > > //event functions; > private var dispatchEvent:Function; > private var addEventListener:Function; > private var removeEventListener:Function; > // > //fired events; > public var onEvent:Function; > > public function EventTry(){ > > EventDispatcher.initialize(this); > this.addEventListener("onEvent",this); > init(); > } > // > private function init(){ > dispatchEvent({type:"onEvent", target:this}); > die(); > } > private function die(){ > removeEventListener("onEvent",this); > this=null; > delete this; > trace("EventTry die"); > } > } > ___ > > And here is the fla code: > > import com.mg.temp.EventTry; > // > var etry:EventTry=new EventTry(); > etry.onEvent=function(){ > trace("onEvent fired"); > } > //end > > ___ > Here I doesn't get the "etry. onEvent" function fired. Also no error, > it just ignore the statement. > Curiously my older classes run well with such a code. > Any help would be appreciate, > thanks, > Javier. > _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders