Posted By

curiousmedia on 10/15/09


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

benwasilewski
TrentSkunk


What am I REALLY clicking on!?


 / Published in: ActionScript 3
 

Will trace the name of the display object that is actually receiving mouse events. Useful when the target of your mouse event is not what you are expecting. Oh, the fix 80% of the time is mouseChildren = false;

  1. addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void{trace(e.target+" : "+e.target.name);});

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: curiousmedia on October 16, 2009

aw, c'mon - no code in comments? seriously?

Posted By: curiousmedia on October 16, 2009
makeEverythingIDselfOnClick(this);

function IDselfOnClick(e:MouseEvent):void
{
    trace("you clicked on ["+e.currentTarget+"] "+e.currentTarget.name);
}
        
function makeEverythingIDselfOnClick(target:DisplayObjectContainer):void
{
    trace("target = " + target.name)
    for(var i:int=0; i<target.numChildren; i++)
    {
        var child = target.getChildAt(i);
        if( (child is InteractiveObject) )
        {
            InteractiveObject(child).addEventListener(MouseEvent.CLICK,IDselfOnClick, false, 0, true);
        }
        if( (child is DisplayObjectContainer)&&(child != target) )
        {
            makeEverythingIDselfOnClick(child);
        }
    }
}   
Posted By: curiousmedia on October 16, 2009

there we go!

Posted By: knalle on October 19, 2009

(oh, i guess I'm just elaborating on thing already posted)

You need to login to post a comment.