Google Maps Flash API Tutorial

This is the second part of the Actionscript 3.0 Google Maps tutorial. In part 1 you learnt how to set up the developer environment. Now it’s time for the real fun part, where you get to write the code. You may want to try some of the simpler tutorials on the Google code site, just to get you feeling more comfortable with the API.

First download the API from Google code

Flash Document class

package code {

	import flash.display.Sprite;
	import flash.display.MovieClip;
	import caurina.transitions.Tweener;

	public class GMapMain extends Sprite {

		public var getMapView:GMapView;
		public var getMapControl:GMapControl;
		public var mapForm2:MovieClip;

		public function GMapMain () {
			addEventListener(Event.ADDED_TO_STAGE, checkStage);
			getMapControl = new GMapControl();


		public function checkStage(e:Event):void {

			getMapControl.x = 160;
			getMapControl.y = 80;

			var getStage2 = stage.getChildAt(0);
			trace ("getStage2 = " +getStage2);



First create the document class – as shown above. The primary function of this class is to initialize the controller class – Since we are using MVC model. The GMapMain adds an even listener on the stage – checkStage, that checks to see if the GMapMain itself has been added to the stage. after this event is fired an instance of GMapControl – getGmapControl is added to the display list.

import flash.display.Sprite;
	import fl.controls.*;
	import flash.display.*;
	import flash.text.*;

	public class GMapControl extends MovieClip {
		public var getButton:Button;
		public var getForm:TextInput;
		public var getTo:TextInput;
		public var getStage2;
		public var getMapView:GMapView;
		static var getAddFrom:String;
		static var getAddTo:String = new String("hello to");

		<span class="style3">public function</span> GMapControl () {
			getMapView = new GMapView();
			addEventListener(Event.ADDED_TO_STAGE, checkStage2);