In the following code we use target in the function:
moon.mouseEnabled = false;
sky0.addChild(moon);
addEventListener(MouseEvent.MOUSE_DOWN, onDrag, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, onDrop, false, 0, true);
function onDrag(evt:MouseEvent):void {
evt.target.addChild(moon);
evt.target.startDrag();
}
function onDrop(evt:MouseEvent):void {
stopDrag();
}
But if I rewrite this code without evt.target
it still work. So what is the difference, am I going to get errors later in the run time because I didn't put target? If not then why some use target a lot while it works without it.
function onDrag(evt:MouseEvent):void {
addChild(moon);
startDrag();
}