Revision: 29620
Updated Code
at June 8, 2011 02:14 by Winkyboy
Updated Code
var previousOUM:String = ""; private function listObjectsUnderMouse():void { var point:Point = new Point(mouseX, mouseY); var objects:Array = stage.getObjectsUnderPoint(point); var currentOUM:String = ""; // Objects Under Mouse var results:String = ""; for (var i:int = 0; i < objects.length; i++) { currentOUM += DisplayObject(objects[i].parent).name if (i != objects.length-1) currentOUM += ", "; } if (currentOUM != previousOUM) { trace(currentOUM); previousOUM = currentOUM; } } // modified/improved version below for pure AS/Flex: // Syntax Application.application.stage.addEventListener(MouseEvent.CLICK, listObjectsUnderMouse); // Variable(s) var previousOUM:String = ""; // Function private function listObjectsUnderMouse(e:MouseEvent):void { var point:Point = new Point(e.stageX,e.stageY); var objects:Array = Application.application.stage.getObjectsUnderPoint(point); var currentOUM:String = ""; // Objects Under Mouse var currentTypes:String = ""; var results:String = ""; for (var i:int = 0; i < objects.length; i++) { currentOUM += DisplayObject(objects[i].parent).name; currentTypes += DisplayObject(objects[i].parent); if (i != objects.length-1) { currentOUM += ", "; currentTypes += ", "; } } if (currentOUM != previousOUM) { trace("\n\n><> " + objects.length + " object(s) under mouse position (" + point.x + "/" + point.y + ").\n><> " + currentOUM + "\n><>" + currentTypes); previousOUM = currentOUM; } }
Revision: 29619
Updated Code
at June 8, 2011 02:13 by Winkyboy
Updated Code
var previousOUM:String = ""; private function listObjectsUnderMouse():void { var point:Point = new Point(mouseX, mouseY); var objects:Array = stage.getObjectsUnderPoint(point); var currentOUM:String = ""; // Objects Under Mouse var results:String = ""; for (var i:int = 0; i < objects.length; i++) { currentOUM += DisplayObject(objects[i].parent).name if (i != objects.length-1) currentOUM += ", "; } if (currentOUM != previousOUM) { trace(currentOUM); previousOUM = currentOUM; } } // modified/improved version below for pure AS/Flex: Application.application.stage.addEventListener(MouseEvent.CLICK, listObjectsUnderMouse); private function listObjectsUnderMouse(e:MouseEvent):void { var point:Point = new Point(e.stageX,e.stageY); var objects:Array = Application.application.stage.getObjectsUnderPoint(point); var currentOUM:String = ""; // Objects Under Mouse var currentTypes:String = ""; var results:String = ""; for (var i:int = 0; i < objects.length; i++) { currentOUM += DisplayObject(objects[i].parent).name; currentTypes += DisplayObject(objects[i].parent); if (i != objects.length-1) { currentOUM += ", "; currentTypes += ", "; } } if (currentOUM != previousOUM) { trace("\n\n><> " + objects.length + " object(s) under mouse position (" + point.x + "/" + point.y + ").\n><> " + currentOUM + "\n><>" + currentTypes); previousOUM = currentOUM; } }
Revision: 29618
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 1, 2010 23:46 by Winkyboy
Initial Code
var previousOUM:String = ""; private function listObjectsUnderMouse():void { var point:Point = new Point(mouseX, mouseY); var objects:Array = stage.getObjectsUnderPoint(point); var currentOUM:String = ""; // Objects Under Mouse var results:String = ""; for (var i:int = 0; i < objects.length; i++) { currentOUM += DisplayObject(objects[i].parent).name if (i != objects.length-1) currentOUM += ", "; } if (currentOUM != previousOUM) { trace(currentOUM); previousOUM = currentOUM; } }
Initial URL
Initial Description
Calling this will conditionally trace the list of object names underneath your mouse point. It will only trace when the list of objects beneath the mouse actually changes.
Initial Title
AS3 Get Object Names from GetObjectsUnderPoint
Initial Tags
Initial Language
ActionScript 3