0 Replies Latest reply on Apr 6, 2011 9:05 AM by BigZ2011

    Trouble accessing Geolocation.addEventListener

    BigZ2011

      Hello, everyone.  I'm bulding my first mobile app in Burrito and I'm having a little trouble with the .  Testing the Geolocation.isSupported property works fine but nothing happens when I try to access the Geolocation.addEventListener property. My code is below.  Any help would be greatly appreciated!

       

      AppHome.xml:

       

       

       

      <fx:Script>

      <![CDATA[

       

       

      import flash.display.Sprite;

       

      import flash.display.StageAlign;

       

      import flash.display.StageScaleMode;

       

      import flash.events.GeolocationEvent;

       

      import flash.sensors.Geolocation;

       

      import flash.text.TextField;

       

      import flash.text.TextFormat;

       

      import mx.events.FlexEvent;

       

      private var g:Geolocation;

       

      private var log:TextField;

       

       

       

      private function gpsRun():void

      {

      setUpTextField();

       

       

       

      if( Geolocation.isSupported )

      {

       

      g =

      new Geolocation();

      g.setRequestedUpdateInterval(100);

       

       

      if( g.muted )

      {

      log.appendText(

      "Geolocation is muted");

       

      return; // Don't do anything if device's sensor is muted.

      }

       

       

      else

      {

      log.appendText(

       

      "geo active"); // This works. Android's satellite icon also turns on.

      g.addEventListener(StatusEvent.STATUS, geoStatusHandler);

       

      // Nothing happens

      g.addEventListener(GeolocationEvent.UPDATE, geolocationUpdateHandler);

       

      // Nothing happens

      }

      }

       

       

      else

      {

      log.appendText(

       

      "Geolocation is not supported");

      }

      lblTest.text += log.text.toString();

      }

      // END gpsRun()

       

       

       

      protected function geoStatusHandler(event:StatusEvent):void

      {

      g.removeEventListener(GeolocationEvent.UPDATE, geolocationUpdateHandler);

      log.appendText(

      "\ngeoStatusHandler() \n"); // Nothing happens

      }

       

       

       

       

      private function geolocationUpdateHandler(event:GeolocationEvent):void // Nothing happens

      {

      lblgeolocationUpdateHandler.text =

       

      "geolocationUpdateHandler()";

      log.appendText(

      "latitude:" + event.latitude.toString() + "°\n");

      log.appendText(

      "longitude:" + event.longitude.toString() + "°\n");

      log.appendText(

      "horizontal accuracy:" + event.horizontalAccuracy.toString() + " m");

      lblTest.text += log.text.toString();

      }

       

       

      private function setUpTextField():void

      {

      log =

       

      new TextField();

       

      var format:TextFormat = new TextFormat("_sans", 24);

      log.defaultTextFormat = format;

      log.border =

      true;

      log.wordWrap =

      true;

      log.multiline =

      true;

       

       

       

       

       

       

       

       

       

      lblsetUpTextField.text =

       

      "setUpTextField";

      }

       

      ]]>

       

      </fx:Script>

       

      AppName-app.xml  <<---------------------<<<<<

       


      <android>
          <manifestAdditions><![CDATA[

      <manifest android:installLocation="auto">

        <!-- See the Adobe AIR documentation for more information about setting Google Android permissions -->

        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
              <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
          <uses-configuration android:reqFiveWayNav="true"/>
          <supports-screens android:normalScreens="true"/>
          <uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch"/>
          <application android:enabled="true">
           <activity android:excludeFromRecents="false">
            <intent-filter>
             <action android:name="android.intent.action.MAIN"/>
             <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
           </activity>
          </application>

      </manifest>

      ]]></manifestAdditions>
      </android>