This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org. [as]interface IAbstract
{
function myAbstractMethod();
}
[/as]
[as]class Abstract
{
private var sub:IAbstract;
// Private constructor disallows instantiation
private function Abstract()
{
// Cast a reference of the extending class instance to the interface type
// which contains the abstract methods.
sub = IAbstract(this);
//Flash Player 7 Only
if(sub == null) // invalid cast will return null in Flash player 7
{
throw("Classes extending Abstract must implement IAbstract");
}
// end Flash Player 7 Only
/* For Flash Player 6 (or 7) use this runtime type check
if(!(sub instanceof IAbstract))
{
sub = null;
trace("Classes extending Abstract must implement IAbstract");
}
*/
//Because sub is of type IAbstract no compiler error is thrown
sub.myAbstractMethod();
}
}
[/as]
[as]class Extending extends Abstract implements IAbstract
{
// methods and properties here.
}
[/as]