5:27 am GMT
Examples
Examples » ActionScript
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();
}
}
This category contains 2
examples, and has been viewed 58414 times.
- XML Properties - An example that works with an XML file (17195 views)
- Abstract Class - An example of an abstract class in Actionscript (13819 views)
|