Tutorial This is from the talent translation of the article cut, but the source program has errors, I changed a bit. Conveniently hangs the original tutorial and the source file (this is one to look at the Flashpaper dozen!) )。 Last listen to a C # lecture, with this vehicle and car; hehe, see how to drive our lovely flash with class.
The project has two categories: Vehicle (superclass) and car (subclass);
Class vehiche{
private Var _npassengers:number;
public Var _nmiles:number;
public Var _ninterval:number;
function Vehicle (npassengers:number,nmiles:number) {
_npassengers=npassengers;
_nmiles=nmiles;
}
...................}
Class Car extends vehiche{
private Var _smake:string;
private Var _smode1:string;
private Var _nyear:number;
function car (smake:string, smode1:string,nyear:number,class car extends vehiche{
private Var _smake:string;
private Var _smode1:string;
private Var _nyear:number;
function car (smake:string, Smode1:string,nyear:number,npassengers:number,nmiles:number) {
Super. Vehicle (npassengers,nmiles);//Super Class
_npassengers=npassengers;
_nmiles=nmiles;
_smake=smake;
_smode1=smode1;
Year=nyear;
}number,nmiles:number) {
Super (Npassengers,nmiles);
_smake=smake;
_smode1=smode1;
Year=nyear;
}
...................}
This is the original, and the constructor in the car class inherits the Npassengers,nmiles parameter from the vehicle constructor. With super (npassengers,nmiles);
As a result, I knocked over a run, no, trace (car.nmiles) =undefined;
After reading the document carefully, I became aware of the use of super, and instead
Super. Vehicle (Npassengers,nmiles);
The result is successful, haha, be the talent to play a pass, think or oneself good from the nature of the good, learn oop see Java bar, hehe!
source file Download: (including source tutorial)
Click to browse the file