我试图将拨动开关设置为禁用并停止地理定位程序......
当 geo 设置为新的 Geolocation 时出现空对象错误 - 我在这里错过了什么?
        private function gogeo():void
        {
            if (Geolocation.isSupported)
            {
                var geo:Geolocation = new Geolocation();
                geo.setRequestedUpdateInterval(2000);
                geo.addEventListener(GeolocationEvent.UPDATE, geolocationUpdateHandler);
            }
            else
            {
                trace("No geolocation support.");
            }   
        }
        private function geolocationUpdateHandler(event:GeolocationEvent):void
        {
            trace("lat:" + event.latitude.toString() + " - ");
            trace("long:" + event.longitude.toString() + "° - ");
            trace("Accuracy:" + event.horizontalAccuracy.toString() + " m");
        }
        protected function toggleswitch1_changeHandler(event:Event):void
        {
            if (toggleswitch1.selected == false) {
            trace("The function should STOP"); 
            geo.removeEventListener(GeolocationEvent.UPDATE, geolocationUpdateHandler);
            geo = null;
        } else {
            trace("The function should RESTART");
            geo = new Geolocation();
            geo.addEventListener(GeolocationEvent.UPDATE, geolocationUpdateHandler);
        }
        }