422537
116 posts
|
Hi,
Does anybody know a directive for displaying x and y coordinates on the stage or in the output window?
|
|
|
JohnnyBohnny
113 posts
|
trace(thing.x+", "+thing.y) ?
|
|
|
422537
116 posts
|
Ok thanks. So what would the word be for tracing the cursor coordinates?
|
|
|
Elyzius
226 posts
|
trace(mouse.x + ", " + mouse.y);
|
|
|
JohnnyBohnny
113 posts
|
You could put it inside a text field
Inside an onMouseMove function, place this:
myTextField.text = mouse.x + ", " + mouse.y
|
|
|
422537
116 posts
|
|
|
|
Aesica
951 posts
|
Originally posted by Elyzius:
trace(mouse.x + ", " + mouse.y);
Just a minor thing, but the quotes, plus signs, etc aren’t necessary with trace statements. This will suffice as well:
trace(mouse.x, mouse.y);
|
|
|
Draco18s
6860 posts
|
Originally posted by Aesica:
Originally posted by Elyzius:
trace(mouse.x + ", " + mouse.y);
Just a minor thing, but the quotes, plus signs, etc aren’t necessary with trace statements. This will suffice as well:
trace(mouse.x, mouse.y);
Yes they are, unless you want this:
15.752.25
As your output.
(Is that 15.75 and 2.25 or 15.7 and 52.25?)
|
|
|
Aesica
951 posts
|
It gives you a courtesy space.
trace("hi", "guise"); // hi guise
trace(mouse.x, mouse.y); // 15.75 2.25
|
|
|
Draco18s
6860 posts
|
Never used it, largely because I like formatting my output in the way I want it formatted.
trace("ThatOneVar: " + someVar);
trace("SomeVarProperties: " + otherThing.prop + ", " otherThing.dohicky);
etc.
|
|
|
Aesica
951 posts
|
If that’s the case, I’m pretty sure my trace statements would make you want to punch a baby. :o
|
|
|
Draco18s
6860 posts
|
Originally posted by Aesica:
If that’s the case, I’m pretty sure my trace statements would make you want to punch a baby. :o
Almost certainly.
I’ll take whole if-statements and put +""+ around the operators (e.g. trace(someX + “>” + value);) to insure that an if statement is being correctly evaluated.
|
|
|
Senekis93
4090 posts
|
What I use to trace:
package{
import org.flashdevelop.utils.FlashConnect;
import flash.utils.getQualifiedClassName;
import flash.system.Capabilities;
public class Log{
private static var
b:Boolean;
public function Log():void{throw "derp.";}
public static function it(S:*="",...args):void{
var
i:int;
if(!Capabilities.isDebugger){
var
t:String=String(S);
if(args)
for(;i<args.length;++i)
t=t+"\t"+args[i];
FlashConnect.trace(((b=!b)?"1: ":"3: ")+t);
return;
}
var
s:String=new Error().getStackTrace(),
ii:int=s.indexOf("()",s.indexOf("()")+1);
i=s.indexOf("at ",s.indexOf("at ")+1)+3;
s=s.substring(i,ii);
var
d:int=s.indexOf("/"),
ss:String=s.substr(d+1);
s=s.substring(0,d);
var
r:String="["+(s?s:ss)+"] ("+ss+") : ";
s=String(S);
if(args)
for(i=0;i<args.length;++i)
s=s+"\t"+args[i];
FlashConnect.trace(((b=!b)?"1: ":"3: ")+r+s);
}
}
}
|
|
|
feartehstickman
521 posts
|
Originally posted by Elyzius:
trace(mouse.x + ", " + mouse.y); Is it not mouseX, mouseY?
|
|
|
Elyzius
226 posts
|
You’re right. I stand corrected.
|
|
|
Aesica
951 posts
|
In a way, you’re both right:
var mouse:Sprite = new sprite();
mouse.addChild(new Assets.Rodent());
mouse.x = cheese.x - mouse.width;
mouse.y = cheese.y;
|