Thank you Brian. I was not thinking properly. Polymorphism was working. That is why I can pass in an event type of LoginEvent. All I have to do is cast it to LoginEvent. ie LoginEvent(event).
--- In [email protected], "Brian Holmes" <[EMAIL PROTECTED]> wrote: > > > > Change your implementation method to something like. > > > > public override function execute(event:Event):void > > { > > if( event is LoginEvent ) > > { > > var loginEvent : LoginEvent = event as LoginEvent; > > > > // do some stuff here > > > > } > > } > > > > > > > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Nathan Arizona > Sent: Wednesday, January 09, 2008 3:01 PM > To: [email protected] > Subject: [flexcoders] Polymorphism help > > > > 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 > > > > > > *** > The information in this e-mail is confidential and intended solely for the individual or entity to whom it is addressed. If you have received this e-mail in error please notify the sender by return e-mail delete this e-mail and refrain from any disclosure or action based on the information. > *** >

