actionscript 3 - AS3 - Detecting if you clicked on an object without pressing the mouse button -


okay, in as3 when click, object on highest layer clicked on. want press space bar , have objects on screen check see if touching point.

so first tried hittest...

if (this.hittest(mypoint)){ play(); }

now problem objects behind other ones thinking being "clicked" on.

then after being frustrated used google, couldn't find please helps.

i think code looking for:

stage.addeventlistener(keyboardevent.key_down, function(e : keyboardevent) : void {     if(e.keycode == keyboard.space) {         var objects : array = stage.getobjectsunderpoint(new point(stage.mousex, stage.mousey));         if (objects.length > 0) {             var topmost : displayobject = objects[objects.length-1];             trace(topmost.name);         }     } }); 

key flash's getobjectsunderpoint method.


Comments