예를 들어 .appendText() 및 array.push와 함께 예기치 않은 결과가있는 GeolocationEvent.UPDATE 예제를보고 actionscript를 처음 보았습니다. 둘 다 전화가 업데이트를 따라갈 수 있는지 여부를 알지 못합니다..appendText는 GeolocationEvent.UPDATE에서 대체하지 않고 마지막 텍스트 위에 쓰고 있습니다.
먼저 텍스트 쓰기 문제는 마지막 쓰기를 덮어 쓰지 않고 덮어 쓰는 것입니다. 전화에서 몇 분 정도 앱을 실행 한 후에는 더 이상 숫자를 읽을 수 없습니다. - this.removeChild()를 사용한 다음 addChild()가 마지막 쓰기를 제거하기 전에 다시 쓰기를 시도하는 것에 관한 것입니다.
두 번째로 배열의 문제는 trace()에서 임의의 .length 숫자를 출력한다는 것입니다. 길이가 다시 계산되기 전에 2로 재설정되는 것처럼 보입니다. 그리고 무작위로 보이는 숫자까지 계산됩니다. 나는 최종 버전에서 배열의 오버 헤드를 원하지 않는다는 것을 알고 있지만 왜 작동하지 않는지 알기 위해 노력하고 있습니다.
내가
var format:TextFormat = new TextFormat();
format.color = 0xff0066;
format.font = "Lucida Console";
format.size = 20;
var fl_GeolocationDisplay:TextField = new TextField();
fl_GeolocationDisplay.defaultTextFormat = format;
fl_GeolocationDisplay.x = 10;
fl_GeolocationDisplay.y = 20;
fl_GeolocationDisplay.selectable = false;
fl_GeolocationDisplay.autoSize = TextFieldAutoSize.LEFT;
//fl_GeolocationDisplay.text = "Geolocation is not responding. Verify the device's location settings.";
fl_GeolocationDisplay.text = " ";
addChild(fl_GeolocationDisplay);
var gpsArray:Array = [42.09646417];
if(!Geolocation.isSupported)
{
fl_GeolocationDisplay.text = "Geolocation is not supported on this device.";
}
else
{
var fl_Geolocation:Geolocation = new Geolocation();
fl_Geolocation.setRequestedUpdateInterval(60000); //android overrides setRequestedUpdateInterval()
fl_Geolocation.addEventListener(GeolocationEvent.UPDATE, fl_UpdateGeolocation);
fl_Geolocation.addEventListener(StatusEvent.STATUS, gpsStatusHandler);
}
function fl_UpdateGeolocation(event:GeolocationEvent):void
{
//gpsArray.push(event.latitude);
//gpsArray[gpsArray.length] = event.latitude;
gpsArray.unshift(event.latitude);
var speed:Number = event.speed * 2.23693629;
if (gpsArray[gpsArray.length - 2] != gpsArray[gpsArray.length - 1])
{
trace(gpsArray.length + "|" + gpsArray[gpsArray.length - 2] + "|" + gpsArray[gpsArray.length - 1]);
trace(gpsArray[1] + "|" + gpsArray[0]);
trace(gpsArray[gpsArray.length - 2] - gpsArray[gpsArray.length - 1]);
}
//this.removeChild(fl_GeolocationDisplay);
fl_GeolocationDisplay.parent.removeChild(fl_GeolocationDisplay);
//fl_GeolocationDisplay = null; //TypeError: Error #2007: Parameter child must be non-null.
addChild(fl_GeolocationDisplay);
fl_GeolocationDisplay.text = (event.latitude.toString() + " | " + event.timestamp.toString());
//fl_GeolocationDisplay.text = (event.latitude.toString() + "\n");
//fl_GeolocationDisplay.appendText(event.latitude.toString() + "\n");
//fl_GeolocationDisplay.appendText(event.longitude.toString() + "\n");
}
function gpsStatusHandler(event:StatusEvent):void {
if (fl_Geolocation.muted) {
fl_GeolocationDisplay.text = "Please verify the device's location settings.";
}
}
단락에서 텍스트 벽을 다시 포맷 할 수 있습니까? 그것은 당신의 문제를 읽고 포착하기가 어렵 기 때문입니다. –
감사합니다. - 내가 더 명확하게 만들었습니다. – user2224471