Archive

Archive for July, 2009

Google Sky, Moon and Mars with gmaps-utility-library-flash

July 19th, 2009 No comments



Reading about google maps I found a utility library for google maps that add the maps of the Sky, Moon and Mars. The library contains more tools.
For more information visit the google code page of this library
http://code.google.com/p/gmaps-utility-library-flash/

GOOGLE SKY EXAMPLE (or press the image to go)
googleSky

GOOGLE MOON EXAMPLE (or press the image to go)
googleMoon

GOOGLE MARS EXAMPLE (or press the image to go)
googleMars

 

Categories: Actionscript 3, Flash Tags:

Tutorial Actionscript 3 – How To Google Maps API

July 19th, 2009 3 comments

The Google Maps API lets you embed Google Maps in your own web pages with JavaScript. The API provides a number of utilities for manipulating maps (just like on the http://maps.google.com web page) and adding content to the map through a variety of services, allowing you to create robust maps applications on your website.

In this post I will explain how to use the Google Maps API.

1.- The first thing that you need is to get your API KEY
Go to http://code.google.com/apis/maps/signup.html

After read and accept the terms and conditions and give your domain name. You will get your key.

googleMaps

2.- The next step is download the library kit of google maps for actionscript and flex.
To download the kit CLICK HERE
The kit contains 2 .swc files with the library.

3.- With the key and api we are ready to start with the code. Create a new project and config the library path to read the swc file downloaded. In your Flash IDE press edit-preferences-actionscript- actionscript 3 and add the folder with your swc files.

4.- THE CODE.

var _map:Map = new Map();
_map.key = "ACA DEBEN PONER SU KEY";
_map.language = "es";
_map.setSize(new Point(stage.stageWidth, stage.stageHeight));
_map.addEventListener(MapEvent.MAP_READY, onMapReady);
_map.y = 50;
addChild(_map);
 
function onMapReady(event:Event):void {
	_map.setCenter(new LatLng(40.736072, -73.992062), 14, MapType.NORMAL_MAP_TYPE);
}

With this simple code we have our example working.

googleMaps

I hope this post help you to understand how works the google maps API. Any question or suggestions are welcome

VIEW EXAMPLE
DOWNLOAD EXAMPLE



Categories: Actionscript 3, Flash Tags:

Tutorial actionscript3 – Loading sound and play as loop

July 10th, 2009 2 comments



DOWNLOAD EXAMPLE

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.net.URLRequest;
 
	/**
	 * This class load a sound and play it in loop.
	 * @author http://www.miguelmoraleda.com
	 */
	public class Main extends Sprite
	{
		private var soundFactory:Sound;
		private var song:SoundChannel;
 
		public function Main()
		{
			super();
 
			loadSound("sound.mp3");
		}
 
		/**
		 * Load the sound
		 * @param	url
		 */
		private function loadSound(url:String):void
		{
			var request:URLRequest = new URLRequest(url);
            soundFactory = new Sound();
            soundFactory.addEventListener(Event.COMPLETE, completeHandler);
            soundFactory.load(request);
		}
 
		/**
		 * When sound is loaded, play it.
		 * @param	e
		 */
		private function completeHandler(e:Event):void
		{
			soundFactory.removeEventListener(Event.COMPLETE, completeHandler);
			playSound();
		}
 
		/**
		 * Play the sound and add listener to sound complete.
		 */
		private function playSound():void
		{
            song = soundFactory.play();
			song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
		}
 
		/**
		 * when the sound is finish play again.
		 * @param	e
		 */
		private function soundCompleteHandler(e:Event):void
		{
			song.removeEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
			playSound();
		}
	}
}

 

Categories: Actionscript 3, Flash Tags:
Get Adobe Flash player