Hi,
i have created a project in FlashDevelop which contains a file called MyVehicle.as which acts as a Super class, MyCar.as which inherits the properties from the super class. I have also created a file called Host.as which is used meant to test the MyCar class by creating an instance of this class and display a “Car2” movieclip symbol(car image) to represent the instance.
The trouble i’m having is trying to create my custome movie clip instance using “MyCar” class in Host.as to be displayed on the stage with the values i’m giving it.
MyCar.as
package
{
/**
* MyCar.as is meant to show how you can inherit from another class, Vehicle and add another property and method
* @author Luong Vuong
* Date created: 13/10/2009
* Last modified: 14/10/2009
*/
import flash.display.Sprite;
import flash.events.Event;
public class MyCar extends MyVehicle
{
public function MyCar(mpg:Number = 12, fuel:Number = 12 ) :void
{
trace("Inside MyCar constructor");
_gasMileage = mpg;
_fuelAvailable = fuel;
}
public function openSunroof() :void
{
trace(this, "opened sunroof");
}
// Class methods
}
}
Host.as
package
{
/**
* Host.as is meant to show how you can use MyCar and display it on screen
* @author Luong Vuong
* Date created: 14/10/2009
* Last modified: 14/10/2009
*/
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
public class Host extends MovieClip
{
private var _compact:MyCar;
public function Host() :void
{
initialize();
construct();
}
// Initialize all variables
public function initialize() :void
{
_compact = new Car2(21, 18)
_compact.openSunroof();
addChild(_compact);
trace(_compact);
}
// Add listeners and add UI to display list
public function construct() :void
{
}
// Class methods
}
}
When building the file i get two errors:
C:\Users\vista\Documents\FlashDevelopProjects\VehicleApp\src\Host.as(32): col: 30 Error: Incorrect number of arguments. Expected no more than 0.
C:\Users\vista\Documents\FlashDevelopProjects\VehicleApp\src\Host.as(32): col: 30 Error: Incorrect number of arguments. Expected no more than 0.
I still want to use my, MyCar class in every way possible and set some values but also use the movieclip symbol, MyCar2, to help display this.
Can somebody tell me what would be the best/common way to solve this problem please.
Thanks