Archive for the ‘AS3’ Tag

IPinfodb ActionScript 3.0 API

Are you looking for the geographical location of an IP address?

IPinfodb offers a you that service, for FREE!

I just ported the service to an ActionScript 3.0 API to open it up for other Flash and Flex developers …

Get your SWC library here. Online documentation for the API.

Add the .SWC file to the libs folder of your flex project.

Calling the API functions, can easily be done.

afbeelding-2

Download the Flex project.

For a sample and more information , please visit my original post on the other blog.

Yahoo! Map Component in Flash CS 3

In this blogpost i will guide you through the process of bringing a Yahoo! map control in to your Flash AS3 project …

At the end of this post , this is what you basicly will get , a basic Yahoo! map … Which i will later explain how you can add the ‘cool stuff’ ….

What will we need before we can get to the fun stuff?

- Like most API’s we will need a developer key , get yours here.

- The Yahoo! Map component , which you can get here. This is not really necessary , but it contains some usefull documentation…

Now its time for the real thing … So open up Flash CS 3

Imports

//Imports
import com.yahoo.maps.api.YahooMap;
import com.yahoo.maps.api.YahooMapEvent;
import com.yahoo.maps.api.core.location.LatLon;

Creating a Yahoo! Map Object in Flash Actionscript CS 3

//Here we will create a new Yahoo map object
var _map:YahooMap = new YahooMap();

Initialising the Yahoo! Map Object in Flash Actionscript CS 3

//A variable of type String which keeps record of our development key (change this is your personal key)
var appid:String = “xLxU4IfV34GgQYVTKlXVMIV4V0M_0mUKqb5m7JWDRF9CIEUoGzqUKyth_uqXd5uW824-”;
//Here we initialize the Yahoo! Map component (our development key , the map widht , the map height)
_map.init(appid,stage.stageWidth,stage.stageHeight);
//Add a event listener to listen to the finish of the initialisation
_map.addEventListener(YahooMapEvent.MAP_INITIALIZE, onMapInit);
function onMapInit(event:YahooMapEvent):void
{
//Pancontrol = the ability to drag the Yahoo! Map around
_map.addPanControl();
//Zoomwidget = Zoom Out and Zoom In control
_map.addZoomWidget();
// TypeWidget = Map Type Buttons
_map.addTypeWidget();
//Setting the beginning zoom level
_map.zoomLevel = 5;
//telling our map component what location will be showed at start up,
//if we forget this, the map will show blank
//Required – Longtitude and Latitude of your favourite location
_map.centerLatLon = new LatLon(50.4026,5.52506);
//Addind our map to the display
addChild(_map);
}