Extending
EventDispatcher in
Flex Builder 3
EventDispatcher in
Flex Builder 3
Ok, so was working on an AS project in Flex Builder 3, and wanted to write a class that extended EventDispatcher. My class was going to receive an XML and dispatch an event when it had transformed the XML into an array of value objects. Since this class wasn’t going to be on the display list, i thought that extending the EventDispatcher class was a good idea.
I created a new actionScript class in Flex Builder and told it to extend the EventDispatcher. When I looked at the auto generated code in the file there, I scratched my head. This is what it looked like:
package com.example {
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
public class Example extends EventDispatcher {
public function Example(target:IEventDispatcher=null) {
super(target);
}
}
}
I was wondering what the target in the constructor was. After some quick research i learned that you only use the EventDispatcher constructor when you have to implement the IEventDispatcher, because you are already extending another class. Therefore i changed my class to look like this instead:
package com.example {
import flash.events.EventDispatcher;
public class Example extends EventDispatcher {
public function Example() {
}
}
}
This wouldn’t have been an issue if i had just written it in TextMate, but because i used Flex Builders auto generating code, i had to investigate what was happening.
Popularity: 4% [?]
Thanks. I asked myself the same question