Why I'm getting the same result when deleting target?
        Posted  
        
            by 
                XNA
            
        on Game Development
        
        See other posts from Game Development
        
            or by XNA
        
        
        
        Published on 2012-08-25T13:37:17Z
        Indexed on 
            2012/09/25
            21:51 UTC
        
        
        Read the original article
        Hit count: 452
        
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();
}
        © Game Development or respective owner