|
|
HomeNewsExamplesDemoDownloadsFAQDocumentationMailing ListsLicense
|
1:07 pm GMT
GeSHi - Generic Syntax Highlighter
Latest News
News Archive
|
Random Screenshot
Demonstration
Runtime Example
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();
}
}
|
|