I have a simple code that seems to be giving strange results.
var startPoint:Point = new Point(x, y); // a point
var r:Number = path[i].row + (-Math.floor((length * 2 + 2) / 2)); // just some math
trace(r); // the math checks out and gives a 3
var tey = startPoint.y + r; //this gives a really strange return....
trace(startPoint.y + r, tey); // this works, and then gives the strange return.
the return is
3
10 7function Function() {}
as
var tey:Number = startPoint.y + r;
trace(startPoint.y + r, tey);
the return is
10 NaN
IDE is FlashDevelop if you feel that information is important.
Additional Info/Testing:
trace(startPoint.y);
traces as
7
:Number
var tey:Number = startPoint.y + r;
trace(tey);
equals
NaN
Number()
var tey = Number(startPoint.y) + r;
trace开发者_如何学编程(tey);
equals
7function Function() {}
(excuse my poor post layout, I'm still inexperienced with stackoverflow's editing system and am working on making this a little cleaner)
I can not reproduce your issue. Your problem is with the X and Y values on this line, probably more so the Y value.
var startPoint:Point = new Point(x, y); // a point
Try hard coding the X and Y to 0
Here is some sample code I ran. This worked as expected, so I will assume its the vars X and Y or something related to the "i" when you access path[i].row
var startPoint:Point = new Point(0, 0); // a point
var r:Number = 3; // just some math
trace(r); // the math checks out and gives a 3
var tey = startPoint.y + r; //this gives a really strange return....
trace(startPoint.y + r, tey); // this works, and then gives the strange return.
I discovered the issue, it was with a part of the code that I appended out of my sample above.
var startPoint:Point = new Point(x, y); // a point
for ( /*for stuff*/ ){
var r:Number = path[i].row + (-Math.floor((length * 2 + 2) / 2)); // just some math
}
trace(r); // the math checks out and gives a 3
var tey = startPoint.y + r; //this gives a really strange return....
trace(startPoint.y + r, tey); // this works, and then gives the strange return.
being var'd inside of the for loop made it act oddly when used outside so I had to move the var assignment outside of the loop and use as normal. A strange occurrence, but I should have knew better.
精彩评论