0 Replies Latest reply on Sep 5, 2009 7:47 PM by bnther

    1046 error GeocoderEvent

    bnther Level 1

      I'm trying this yahoo maps application tutorial that I found in a Flash&Flex magazine and I'm stuck.  I keep getting the 1046; Type was not found or not compile time constant.  I'm pretty sure that I imported everything, but maybe not.  This is my first time with a 'GeocoderEvent'.  Any thoughts would be appreciated.

       

      Here's the code:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="600" creationComplete="init()">
          <mx:UIComponent id="mapholder" width="100%" height="100%" />
          <mx:Script>
              <![CDATA[
                  import com.yahoo.maps.api.YahooMap;
                  import com.yahoo.maps.api.YahooMapEvent;
                  import com.yahoo.maps.api.core.location.Address;
                  import com.yahoo.maps.webservices.geocoder.GeocoderResult;
                  import com.yahoo.maps.webservices.geocoder.GeocoderEvent;
                  import mx.controls.Alert;
                  import flash.events.*;
                 
                  private var _yahooMap:YahooMap;
                  private var _address:Address;
                  private var _appId:String ="I took this out for privacy reasons";
                 
              // initializing           
                  private function init():void{
                      // new map
                      _yahooMap = new YahooMap();
                      // set width & height
                      _yahooMap.init(_appId, mapHolder.width, mapHolder.height);
                      //controls
                      _yahooMap.addPanControl();
                      _yahooMap.addZoomWidget();
                      _yahooMap.addTypeWidget();
                      // add map object
                      mapHolder.addChild(_yahooMap);
                      // searching for Bucharest ?
                      geocodeAddress("Bucharest");
                  }
              //from Bucharest to geocode coordinates           
                  private function geocodeAddress(value:String):void{
              // new address object
                      _address = new Address(value);
                      // success and failure events
                      _address.addEventListener(GeocoderEvent.GEOCODER_SUCCESS, address_geocoderSuccess);
                      _address.addEventListener(GeocoderEvent.GEOCODER_FAILURE, address_geocoderFailure);
                      _address.geocode();
                  }    
                 
              // geocoder success -- found the location
                 private function address_geocoderSuccess(evt:GeocoderEvent):void{
                      var result:GeocoderResult = Address(evt.target).geocoderResultSet.firstResult;
                      // setting map to the found location
                      _yahooMap.centerLatLon = result.latlon;
                      //setting zoom
                      _yahooMap.zoomLevel = result.zoomLevel;
                  }       
                 
                  // geocoder failure -- didn't find the location
                  private function address_geocoderFailure(evt:GeocoderEvent):void{
                      Alert("Unable to get address " + _address.address);
                  }
              ]]>
          </mx:Script>
      </mx:Application>