I am passing in a custom event that extends Event into a class that
implements an interface. I get an incorrect signature and I am
wondering why? Why do I not get the benefit of polymorphism?
I have an interface as follows:
package myCom.controller
{
import flash.events.Event;
public interface ICommand
{
function execute(event:Event):void
}
}
I have a pseudo abstract class as follows:
package myCom.controller
{
import flash.events.Event;
import myCom.view.events.LoginEvent;
public class Command implements ICommand
{
public function execute(event:Event):void
{
}
}
}
Here is a LoginCommand that extends the Command Class
package myCom.controller
{
import flash.events.Event;
import myCom.view.events.LoginEvent;
import myCom.model.DashboardModel;
import mx.rpc.remoting.RemoteObject;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import myCom.model.User;
import com.adobe.crypto.MD5;
public class LoginCommand extends Command
{
public function LoginCommand() {
}
public override function execute(event:LoginEvent):void {
}
public function myResult(event:ResultEvent):void {
var temp:User;
temp = User(event.result);
trace("myEvent is done");
}
public function resultFault(event:FaultEvent):void {
trace("myeventFault" + event.message.toString());
}
}
}
I get an error saying that I have an incompatible signature because my
execute function is expecting a LoginEvent. The LoginEvent extends
Event. Commands execute signature expects an Event. Why do I not get
the advantage of polymorphism here?
Thanks for your insight.
Arizona