Gather 'round children, and I will describe to you the 1203 error in child friendly Layman's Terms.
"
1203 No default constructor found in base class %s. You must explicitly call the constructor of the base class with a super() statement if it has 1 or more required arguments."
When you extend a class in AS3, flash will automatically add a function that initializes the class that you are extending.
For example, let's say you have a "ship" class. When you create this class, you have a whole bunch of functions that create walls, shields, passenger compartments, motors, etc.
ActionScript Code:
public class Ship
{
public function Ship():void
{
//Here you will build the ship, and make sure it is functional.
this.buildHullAndWalls();
this.buildPassengerCompartments();
this.addElectronics();
this.addNavigation();
this.addMotors(new HyperDrive(), new SublightEngine());
this.addSheilds();
if (this.scanForDefects())
{
emailCaptain("Ship is in working order and ready to go! :) ");
}
else
{
emailCaptain("There is something wrong! There are problems with this ship still!");
throw new ShipBuildError("An error occured when building the ship. Please wait for repairs.");
}
}
}
Now, when you want to extend a class, it is like
creating a new version of the parent class AND adding to it.
So to create a Cruiser (basically a basic ship with weapons), you could write all this out:
ActionScript Code:
public class Cruiser
{
public function Cruiser():void
{
//Here you will build the ship, and make sure it is functional.
this.buildHullAndWalls();
...
this.addSheilds();
this.addWeapons();
if (this.scanForDefects())
{
...
}
}
}
But doing this for each and every ship that extends the Ship is long, tedious, and memory consuming. Also, if you want to make any changes to the way the ship works (for example, adding the shields before you add the motors), you have to go back and change that code in every single ship that is built from a Ship, or extends the Ship.
So to have the Cruiser extend Ship:
ActionScript Code:
public class Cruiser extends Ship
{
public function Cruiser():void
{
this.addWeapons();
}
}
This simplifies making ships
immensely, however, we have one (major) problem. Here, you are telling the crew to start adding weapons to the ship. That's fine and dandy, but where is the ship? You haven't told the crew to start building a ship yet! How are they supposed to add on the weapons?
Luckily, The Flash Compiler (known to his friends as "Foreman Flash") realizes this, so when you tell the crew to start building the ship, Flash looks through the list of tasks for the crew to do. He realizes that you are technically building a ship, and since the builders can't add anything to the ship until the ship is built, he adds a task for the builders at the start of the list. He tells them "
First, build a standard ship, like the one you made for Larry last month.
Then, add weapons to it, and make it a cruiser instead."
ActionScript Code:
public class Cruiser extends Ship
{
public function Cruiser():void
{
super(); //This means, do everything that the super class (or Ship) does to start out.
this.addWeapons(); //Now you can add weapons when you have a ship built!
}
}
That's OOP 101. However, sometimes things get a little more complicated than that. What if in order to build the standard Ship, the builders have to know how many passengers it will hold. Otherwise, they don't know if they should build a little or a small ship.
ActionScript Code:
public class Ship
{
public function Ship(howManyPassengers:Number):void
{
//Here you will build the ship, and make sure it is functional.
this.buildHullAndWalls();
this.buildPassengerCompartments(howManyPassengers);
this.addElectronics();
this.addNavigation();
this.addMotors(new HyperDrive(), new SublightEngine());
this.addSheilds();
if (this.scanForDefects())
{
...
}
}
}
Now we run into a problem. Foreman Flash has the task of building another Cruiser. As usual, he looks through the list to check if the ship can be built, so cruiser weapons can be added to it. Realizing that someone forgot that command, he
again adds
super() to the list, and the builders start working.
The builders start gathering supplies, when one person calls out "Wait a minute! How big is this ship supposed to be? Foreman Flash, we do not know how many passengers this thing will hold!"
Foreman flash looks at his clipboard again and again, but he has no idea of how big the client wanted the cruiser. He is now confused, and the builders are getting angry. Guessing a random numbe could be disasterous.
"1203 No default constructor found in base class! Help! I'm confused! No one ever told me what to do! I can't build without proper instructions!"
There is your error.
Next time, the ship buying millionare is smarter. When he orders a Cruiser, he says "I want the ship to hold 24,000 passengers. Get it done right this time."
ActionScript Code:
//This code is run elsewhere, perhaps on the main timeline
var NumberOfPassengersForMyCruiser:Number = 24000;
var MyPimpedOutCruiser:Cruiser = new Cruiser(NumberOfPassengersForMyCruiser);
//Here is the actual class located elsewhere.
public class Cruiser extends Ship
{
public function Cruiser(passengers:Number):void
{
super(passengers); //Now we add building the ship to the list so the Foreman doesn't have to worry about adding it himself.
this.addWeapons(); //Now you can add weapons, because the builders know how big the ship will be!
}
}
Another way of doing this, is perhaps there is a law in place which states that all cruisers must be built for 40,000 passengers. No more, no less.
ActionScript Code:
public class Cruiser extends Ship
{
public function Cruiser():void
{
super(40000); //Because the super() command just won't suffice!
this.addWeapons(); //Now you can add weapons, because the builders know how big the ship will be!
}
}
Or, if you are really smart, you could change the plans of the Ship design to say that, unless you hear anything differently, the ship will always be built for 30,000 passengers.
ActionScript Code:
public class Ship
{
public function Ship(howManyPassengers:Number = 30000):void
{
//Here you will build the ship, and make sure it is functional.
this.buildHullAndWalls();
this.buildPassengerCompartments(howManyPassengers);
this.addElectronics();
this.addNavigation();
this.addMotors(new HyperDrive(), new SublightEngine());
this.addSheilds();
if (this.scanForDefects())
{
...
}
}
}
Now the Cruiser class can look like this:
ActionScript Code:
public class Cruiser extends Ship
{
public function Cruiser(passengers:Number):void
{
//Don't bother adding the super() command here. The Foreman will do it automatically. That's what he's getting paid for. :)
//You can add it if you want to, but I say it is a waste of your time.
this.addWeapons();
}
}
When the Foreman looks through the list, he sees that you never told the workers start building the ship. "No problem, I'll just add the super() command here."
Then the builders receive their instructions. "
First, build a ship,
then add weapons to it. Wait! The foreman never told us how many passengers he want the ship to hold. Oh well, by default, they want 30,000 passengers, so we will just do what we usually do."
No errors. Everyone is happy.
Now. To go back to your code...
ActionScript Code:
package
{
import com.RadarPoint;
public class Rp1 extends RadarPoint
{
function Rp1():void
{
trace("YEAY! New RadarPoint child RP1 created!");
}
}
}
The Foreman looks through this code, and sees that you are building a RadarPoint, but you never told the workers to start building the RadarPoint! Proposterous! He quckly adds it to the list and send the workers on their way.
ActionScript Code:
import com.RadarPoint;
public class Rp1 extends RadarPoint
{
function Rp1():void
{
super(); //Added by the foreman.
trace("YEAY! New RadarPoint child RP1 created!");
}
}
So the workers look at the list, and start building a Radar Point. "Woah!! Big problem!! Foreman!!! We don't know what the values of
newProp1:int, newProp2:Number, and
newProp3:String are supposed to be!!"
ActionScript Code:
import flash.display.Sprite;
public class RadarPoint extends Sprite
{
function RadarPoint(newProp1:int, newProp2:Number, newProp3:String):void
{
this._prop1 = newProp1;
this._prop2 = newProp2;
this._prop3 = newProp3;
}
}
Next time, when the millinaire is ordering his brand new RP1, he remembers to tell the foreman and the builders what specifications he wants, avoiding any confusion:
ActionScript Code:
package
{
import com.RadarPoint;
public class Rp1 extends RadarPoint
{
function Rp1():void
{
super(3467, -345.37327, "Red/Blue");
trace("YEAY! New RadarPoint child RP1 created!");
}
}
}
Moral of the story, always tell Foreman Flash what to do, otherwise he gets mad and thows errors and swearwords in your way.I should win a Pulizer.