# Google Map AS3 error. 1046

**URL:** https://forum.kirupa.com/t/google-map-as3-error-1046/315641
**Category:** flash
**Created:** [October 31, 2010, 4:32pm UTC](https://forum.kirupa.com/t/google-map-as3-error-1046/315641 "2010-10-31T16:32:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Bark\_Off](https://avatars.discourse-cdn.com/v4/letter/b/f07891/32.png) [@Bark\_Off](https://forum.kirupa.com/u/Bark_Off)
#### Post date: [October 31, 2010, 4:32pm UTC](https://forum.kirupa.com/t/google-map-as3-error-1046/315641/1 "2010-10-31T16:32:20Z")

</div>

[http://www.kirupa.com/developer/as3/flash\_as3\_google\_maps\_api\_pg2.htm](http://www.kirupa.com/forum/../developer/as3/flash_as3_google_maps_api_pg2.htm)  
1046: Type was not found or was not a compile-time constant: DirectionsEvent.  
I highlighted the line with error in RED. The code is as follows:  
import com.google.maps.LatLng;  
import com.google.maps.Map;  
import com.google.maps.MapEvent;  
import com.google.maps.MapType;  
import com.google.maps.InfoWindowOptions;  
import com.google.maps.LatLngBounds;  
import com.google.maps.MapMoveEvent;  
import com.google.maps.overlays.Marker;  
import com.google.maps.overlays.MarkerOptions;  
import com.google.maps.interfaces.IPolyline;  
import com.google.maps.services.\*;

var dir:Directions;  
var polyline:IPolyline;  
var map:Map

function setupMap() {  
map = new Map();  
map.key=“ABQIAAAAh8LfxQ8YLf1biQWzuFIxzxQSOn345XElUGjUlW3\_TRSFT8fI1BSxauGJGfMCQCKzhMONHnGM-4nk1Q”;  
map.setSize(new Point(400,400));  
map.x=0;  
map.y=0;  
map.addEventListener(MapEvent.MAP\_READY, onMapReady);  
this.addChild(map);  
}  
setupMap();

function onMapReady(event:Event):void {  
dir = new Directions();  
dir.addEventListener(DirectionsEvent.DIRECTIONS\_SUCCESS,onDirectionsLoaded);  
dir.load(“121 Kings Road, Westampton, NJ to 300 Mill Street, Bristol, PA”);  
}  
function onDirectionsLoaded(event:DirectionsEvent):void {  
[COLOR=Red]var returnedDirection:Directions=event.directions;[/COLOR]

```
var startLatLng:LatLng=returnedDirection.getRoute(0).getStep(0).latLng;
var endLatLng:LatLng=returnedDirection.getRoute(returnedDirection.numRoutes-
                                                1).endLatLng;

polyline=returnedDirection.createPolyline();

map.clearOverlays();
map.addOverlay(polyline);
map.addOverlay(new Marker(startLatLng));
map.addOverlay(new Marker(endLatLng));
map.setCenter(returnedDirection.bounds.getCenter(),
                                                  map.getBoundsZoomLevel(returnedDirection.bounds));

```

## }

I changed the Google API Key and the address that were in the code found on this site.  
is there an easy fix for this?
