Hi i am using FlashDevelop and i have created 2 very simple classes,
Vehicle.as
package
{
/**
* Vehicle.as is meant to show a vehicle class
* @author Luong Vuong
* Date created: 29/09/2009
* Last modified: 30/09/2009
*/
import flash.display.MovieClip;
import flash.events.Event;
public class Vehicle extends MovieClip
{
public var _gasMileage:Number;
public var _fuelAvailable:Number;
public var _milesTraveled:Number = 0;
public var _go:Boolean;
//public var vehicle:Vehicle = new Vehicle(21, 18);
public function Vehicle(mpg:Number = 21, fuel:Number = 18) :void
{
_gasMileage = mpg;
_fuelAvailable = fuel;
this.addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);
construct();
}
public function construct() :void
{
//addChild(vehicle);
//vehicle.go();
}
public function onLoop(evt:Event) :void
{
if (_go)
{
_fuelAvailable--;
_milesTraveled += _gasMileage;
if ( _fuelAvailable < 1 )
{
this.removeEventListener(Event.ENTER_FRAME, onLoop);
}
trace(this, _milesTraveled, _fuelAvailable);
this.x = _milesTraveled;
}
}
// Start engine and drive
public function go() :void
{
_go = true;
}
}
}
VehicleOnly.as
package
{
/**
* VehicleOnly.as is meant to show
* @author Luong Vuong
* Date created: 30/09/2009
* Last modified: 30/09/2009
*/
import flash.display.Sprite;
import flash.events.Event;
public class VehicleOnly extends Sprite
{
public var vehicle:Vehicle = new Vehicle(21, 18);
public function VehicleOnly() :void
{
initialize();
construct();
}
// Initialize all variables
public function initialize() :void
{
addChild(vehicle);
}
// Add listeners and add UI to display list
public function construct() :void
{
vehicle.go();
}
// Class methods
}
}
When i create an instance of the Vehicle class in my VehicleOnly.as file and send the values to my constructor, and run the appplication, it does not show any output to my Output panel. I should be getting the following:
[object Vehicle] 21 17
[object Vehicle] 42 16
…
[object Vehicle] 336 2
[object Vehicle] 357 1
[object Vehicle] 378 0
can somebody tell me exactly why i am not getting this??
Thanks