工程有两个类:Vehicle(superClass)和Car(subClass);
classVehiche{
privatevar_nPassengers:Number;
publicvar_nMiles:Number;
publicvar_nInterval:Number;
functionVehicle(nPassengers:Number,nMiles:Number){
_nPassengers=nPassengers;
_nMiles=nMiles;
}
...................}
classCarextendsVehiche{
privatevar_sMake:String;
privatevar_sMode1:String;
privatevar_nYear:Number;
functionCar(sMake:String,sMode1:String,nYear:Number,classCarextendsVehiche{
privatevar_sMake:String;
privatevar_sMode1:String;
privatevar_nYear:Number;
functionCar(sMake:String,sMode1:String,nYear:Number,nPassengers:Number,nMiles:Number){
super.Vehicle(nPassengers,nMiles);//超类
//_nPassengers=nPassengers;
//_nMiles=nMiles;
_sMake=sMake;
_sMode1=sMode1;
year=nYear;
}Number,nMiles:Number){
super(nPassengers,nMiles);
_sMake=sMake;
_sMode1=sMode1;
year=nYear;
}
...................}
这是原文,Car类中的构造函数中要继承Vehicle的构造函数中的nPassengers,nMiles参数。用super(nPassengers,nMiles);
结果我敲完了一run,不行,trace(car.nMiles)=undefined;
仔细看完了文档后才清楚了一点super的用法,于是改为
super.Vehicle(nPassengers,nMiles);
结果成功,哈哈,被达人玩了了一通,想想还是自己好好从本质上下手的好,学oop看java吧,呵呵