The GMapControl.as snippet above shows the variable declarations and constructor.
This class creates the form text fields and submit button. It also listens for button click and sends the START and END addresses to the view class. The GMapView instance getMapView is also created and added to the stage.

public function checkStage2(e:Event) {
			trace("GMapControl check stage");
			trace(stage);
			getButton = new Button();

			getForm = TextInput (getChildByName("addFrom"));
			getTo = TextInput (getChildByName("addTo"));
			getButton = Button( getChildByName("getDirections"));

			getButton.addEventListener(MouseEvent.CLICK, showDirections);
			trace("button = " +getButton);
			stage.addChild(getMapView);
			getMapView.initMap();
		}
		public function showDirections(event:MouseEvent):void {
			trace("addToGeocode");
			if(stage.getChildByName("getMapView")) {
				stage.removeChild(getMapView);
			}


			getForm = TextInput (getChildByName("addFrom"));
			getTo = TextInput (getChildByName("addTo"));
			getAddFrom = getForm.text;
			getAddTo = getTo.text;
			trace("getAddFrom = "+getAddTo);
			if(getMapView.mapLoaded){
				trace("map IS loaded inControl");

				GMapView.getMap.unload();
				getMapView.mapLoaded = false;

				}
			if(stage.getChildByName("getMapView") != null) {

				trace("map = null");
				getMapView = null;
			}
			if(!getMapView.mapLoaded) {
			stage.addChild(getMapView);
			trace("CLICK AddChild");
			trace("stage ChildNUM is" +stage.numChildren);

			GMapView.getMap.y = 40;
			GMapView.getMap.x = 310;
			getMapView.loadDir(getAddFrom,getAddTo);
						}

				}

	}

The last part of GMapView above shows the event listener checkStage2, which is like the checkStage in GMapMain it listens for when GMapControl is added to stage before initializing GMapView instance getMapView and it’s contents. Namely the get directions button and START / END address text fields. Finally the getMapView instance is initialized with the initMap() method.
The showDirections() method then loads the map after reading the START and END addresses from the text fields.

package code {
	/*
	Google Map View Class creates the map object and adds the marker and polyline overlays
	Creates an instance of DirectionsGrid class

	*/

	import flash.display.*;
	import flash.events.*;
	import com.google.maps.LatLng;
	import com.google.maps.Map;
	import com.google.maps.MapEvent;
	import com.google.maps.MapType;
	import com.google.maps.overlays.*;
	import com.google.maps.InfoWindowOptions;
	import com.google.maps.MapMouseEvent;
	import com.google.maps.services.*;
	import com.google.maps.LatLngBounds;
	import com.google.maps.interfaces.IPolyline;
	import com.google.maps.controls.*;
	import com.google.maps.MapsClientLibrary;
	import fl.controls.*;
	import flash.text.*;
	import flash.geom.Point;
	import fl.controls.DataGrid;
	import fl.controls.ScrollPolicy;
	import fl.events.*;
	import fl.controls.dataGridClasses.DataGridColumn;
	import fl.data.DataProvider;
	import fl.transitions.*;
 	import fl.transitions.easing.*;
	import flash.media.*;
	import flash.media.SoundTransform;
	import caurina.transitions.Tweener;

	import myIcon;

You need to import all the packages shown above.

	public class GMapView extends MovieClip {
		static var getMap:Map = new Map();
		public var myMarker:Marker;
		public var startMarker:Marker;
		public var endMarker:Marker;
		public var stepMarker:Marker;

		public var dir:Directions;
		static var gridDir:Directions;
		public var options:MarkerOptions = new MarkerOptions();
		public var options2:MarkerOptions = new MarkerOptions();
		public var optionsStart:MarkerOptions = new MarkerOptions();
		public var optionsEnd:MarkerOptions = new MarkerOptions();
		public var optionsInfoEnd: InfoWindowOptions;
		public var geoCoder:ClientGeocoder;
		public var directionBounds:LatLngBounds;
		public var myZoomControl: ZoomControl;
		public var myMapTypeControl: MapTypeControl;
		public var getStage;
		public var getMapControl;
		public var mapHolder:MovieClip;
		public var getAddFrom:TextInput;
		public var getAddTo:TextInput;
		public var getCurrAdd:String;
		public var getDestAdd:String;
		public var driveDirections:TextField;
		public var dpDirections:DataProvider;
		public var gridDirection:DirectionsGrid;
		public var mapLoaded:Boolean;
		private var rollSound:RollSound = new RollSound();
		private var errorSound:ErrorSound = new ErrorSound();
		public var playIt:SoundChannel;

			public function GMapView() {
			trace("new GMAPVIEW $$$$$$ ***********");
			addEventListener(Event.ADDED_TO_STAGE, checkStage);
			mapLoaded = false;
			options.icon = new myIcon();
			options.icon.alpha = 0.5;
			options2.icon = new animMarker1();
			optionsStart.icon = new animMarkerStart();
			optionsEnd.icon = new animMarkerEnd();
			optionsStart.icon.alpha = 0.9;
			optionsEnd.icon.alpha = 0.9;
			options2.hasShadow = false;
			getMap.key = "ABQIAAAA6bNu88Ofg-y65sTTgSkZ3BRgi2om1Pm8LwsX-qW_wRwnwD86kRTp0oU44rBxRcIFnyVfRv4PwLDMSg";
			//map.setSize(new Point(stage.stageWidth, stage.stageHeight));
			//getMap.setSize (new Point (500, 500));
			//getMap.addEventListener(MapEvent.MAP_READY, onMapReady);
			this.mapHolder = new MovieClip();


		}