Hi.
This will work:
addVolvo.addEventListener(MouseEvent.CLICK, addCar);
function addCar(evt:MouseEvent)
{
var car1:Car = new Car( 1, 1, classVolvo)
}
// MouseEvent is automatically passed
… but I want to pass the a value when calling the function:
addVolvo.addEventListener(MouseEvent.CLICK, addCar(classVolvo));
function addCar(evt:MouseEvent, newClass:Class)
{
var car1:Car = new Car( 1, 1, classVolvo)
}
// I will get this error:
// 1136: Incorrect number of arguments. Expected 2. [addCar(classVolvo)]
This won’t work. Because it then just passes the Class and not the MouseEvent. How can I solve this? What should I write in the addCar(…) call function? Ie how to I manually pass an MouseEvent, if that’s what I’m supposed to do?