Monday, June 23, 2008

flash debugging trick




A little trick I learned when debugging some Flash in haXe:

I had an event callback that looked like:


function mouseDownListener (e:MouseEvent):Void {
trace("e=" + e.target.name);
}


Which would give me the name for the object that I clicked on. It would just give me a name like "instance15" which wasn't very helpful.

It's easy to make it more readable, just set the name of the Sprite when you create it:


drag_icon = new Sprite();
drag_icon.name = "drag icon"; // sness - For debugging, very handy.
well.addChild(drag_icon);