public class ChildClass extends MovieClip
{
public function ChildClass()
{
}
public function aChildClassFunction()
{
}
}
public class AnotherChildClass extends MovieClip
{
public function ChildClass()
{
}
public function aChildClassFunction()
{
}
}
Some random function that asks for childClass ( But a lazy programmer just uses MovieClip class )
public function setChildClassInstance(var mc:MovieClip)
{
// How come "mc" represent and be allowed as parameter ??? It's a super-class.. ie. structurally a sub-set of child-class.
mc.aChildClassFunction(); //<< Would generate run-time error for 2nd function call.
}
The above function can be used for any MovieClip instance also
var childClassInstance:ChildClass ;
var anotherChildClassInstance:AnotherChildClass ;
setChildClassInstance( childClassInstance ) // <<<<<VALID, .... NO COMPILER ERROR
setChildClassInstance( anotherChildClassInstance )
//<<< VALID, NO COMPILER ERROR .. BUT WILL CAUSE RUNTIME ERROR !!!!
//
//
//
I wonder, how come SUPER CLASS (MovieClip here) be allowed and represent themeselves as parameter for child-classes ( here: ChildClass, AnotherChildClass). Especially because, "SUPERCLASSES" actually are "SUB-SET" of their PARENT-SET , ie. their child-class.
Thanks