class Abstract { privatevar sub:IAbstract; // Private constructor disallows instantiation privatefunction 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(); } }