To quote the first line of the web page you reference: "In more precise terms, polymorphism (object-oriented programming theory) is the ability of objects belonging to different types to respond to method calls of methods of the same name, each one according to an appropriate type-specific behaviour."

Even though sub-classing is one way to achieve similar interfaces, it's also common to use interfaces depending on your needs.

interface Bar {
  function toString() {}
}
class Foo implements Bar {
  function toString() { trace("I'm Foo"); }
}
class Goo implements Bar {
  function toString() { trace("I'm Goo"); }
}
var objs:Array = new Array(3);
objs[0] = new Foo();
objs[1] = new Goo();
objs[2] = 12345;

// The following is an example polymorphism.  You are
// calling the same method on multiple objects regardles
// of their type because they all have a method with the
// name toString() but perform type-specific behaviour
trace( objs[0].toString() );
trace( objs[1].toString() );
trace( objs[2].toString() );

James O'Reilly - JOR
www.jamesor.com


Jeroen Beckers wrote:
You can't 'choose' the definition of polymorphism :p.

"In simple terms, *polymorphism* lets you treat derived class members just like their parent class's members." Source: http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming (+ all my java & AS books)

class Foo extends Bar
{

}

var myFoo:Bar = new Foo(); //this is polymorphism !

Giles Taylor wrote:

http://en.wikipedia.org/wiki/Polymorphism_(computer_science)
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Meinte
van't Kruis
Sent: 25 August 2006 14:14
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OOP methodology and flash. I'm loosing my
faith...

well, I get Interfaces, but thanks for explaining :).

I just don't think actionscript, or java, has any polymorphism, since
the definition of that is, in my opinion, a class having more than one
parent class (ie, can extend 2 or more classes), which isn't the case.
So I don't understand why people who are explaining oop in actionscript
talk about polymorphism, because it just isn't there :), but perhaps I'm
wrong.

cheers,
-Meinte
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to