I have learned this method of passing values with addEventLister. Here is the code:
for (var i:uint = 0; i < asteroids.length; i++)
{
asteroids[i].x = M
Why don't you declare the function like normal, rather than in the parameter? You can do the following:
for (var i:uint = 0; i < asteroids.length; i++)
{
asteroids[i].x = Math.random() * 450;
asteroids[i].y = Math.random() * 450;
asteroids[i].addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
});
}
public function onMouseUp(e:MouseEvent) {
changeValue(e, otherArguments);
}
public function changeValue(event:MouseEvent, otherArguments:Object):void
{
playSound(anote);
trace(event.currentTarget);
}
You can remove it as follows:
asteroids[index].removeEventListener(MouseEvent.MOUSE_UP, onMouseUp)