I'm sure the long/latitudes return as converted to [text] string. No need for .toString
method.
Correct way to trace is example: trace("my latitude is.. " + event.location);
In your code try like this:
trace( "lat = " + event.latitude );
trace( "lng = " + event.longitude );
trace( "Star.x = " + (((lng * Math.PI / 180) - (MinLongitude... etc
trace( "Star.y = " + (((lat * Math.PI / 180) - (MinLatitude... etc
Edit:
I just realised you're casting int
as the type for your four vars (var MinLongitude:int
etc) but also setting them up with fractional inputs. Int's
cannot be fractions or have decimal places so change those types to Number
eg: (var MinLongitude:Number
) etc. Hopefully now you'll get good results.
Otherwise seems there is nothing with your calculation formula. So minus infinity is strange. I did manual calculation...
Star.x = (((lng * Math.PI / 180) - (MinLongitude * Math.PI / 180)) / ((MaxLongitude * Math.PI / 180) - (MinLongitude * Math.PI / 180)) / Map.width));
in calculator becomes: (assume Map.width = 500, Math.PI = 3.14)...
(25.33213 * 3.14 / 180) - (25.139585 * 3.14 / 180) / (25.332134 * 3.14 / 180) - (25.139585 * 3.14 / 180) / 500
and the result 6.077202837190 etc.... so Star.x = 6.0