forked from: Modest Maps Example
BSD License http://modestmaps.com/license.txt
see http://modestmaps.com/
copied from ModestMaps-AS3-1.0-latest/as3/samples/as3/ModestMapsExamples/HelloMap.as
// forked from mash's Modest Maps Example
// BSD License http://modestmaps.com/license.txt
// see http://modestmaps.com/
// copied from ModestMaps-AS3-1.0-latest/as3/samples/as3/ModestMapsExamples/HelloMap.as
package {
import com.modestmaps.Map;
import com.modestmaps.TweenMap;
import com.modestmaps.events.MapEvent;
import com.modestmaps.extras.MapControls;
import com.modestmaps.extras.MapCopyright;
import com.modestmaps.extras.ZoomSlider;
import com.modestmaps.mapproviders.microsoft.MicrosoftHybridMapProvider;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.media.*;
import flash.system.*;
import flash.text.*;
import flash.utils.*;
import com.adobe.serialization.json.*;
import com.adobe.serialization.json.JSON;
[SWF(backgroundColor="#ffffff")]
public class HelloMap extends Sprite
{
public var map:Map;
public function HelloMap()
{
inittrace(stage);
testJSON();
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
map = new TweenMap(stage.stageWidth, stage.stageHeight, true, new MicrosoftHybridMapProvider());
map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick);
addChild(map);
map.addChild(new MapControls(map));
map.addChild(new ZoomSlider(map));
map.addChild(new MapCopyright(map));
// make sure the map fills the screen:
stage.addEventListener(Event.RESIZE, onStageResize);
}//constructor
public function onStageResize(event:Event):void {
map.setSize(stage.stageWidth, stage.stageHeight);
}
public function testJSON():void {
var tags:Array;
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest();
request.url="http://api.flickr.com/services/rest/?method=flickr.places.getInfo&api_key=9fd414a14e7cb7378546995888aea55f&woe_id=123&format=json&jsoncallback=?";
loader.load(request);
loader.addEventListener(Event.COMPLETE, decodeJSON);
function decodeJSON(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace("Before JSON Decoding");
//trace(loader.data);
var test:String = loader.data;
// Take out excess so JSON string is valid
//test = test.replace("jsonFlickrFeed(", "");
//test = test.substring(0,test.length -1);
//trace(test);
// Decode the JSON string to an object
var jsonObject:Object = JSON.decode(test);
//trace( jsonObject);
//trace( jsonObject);
var People:Array = JSON.decode(test);
trace(jsonObject);
/* for (var i:uint = 0; i < jsonObject.place.length; i++) {
trace("hello");
//trace("\nUID: "+ jsonObject.userArray[i].uid);
//trace("Name: "+ jsonObject.userArray[i].name);
//trace("Age: "+ jsonObject.userArray[i].age);
}*/
}//end decode json
}//initJSON
}//class
}//package
///// WONDERFL TRACE /////
import flash.display.Sprite;
import flash.display.Stage;
import flash.text.TextField;
import flash.text.TextFormat;
function inittrace(s:Stage):void
{
WTrace.initTrace(s);
}
//global trace function
var trace:Function;
//wtreace class
class WTrace
{
private static var FONT:String = "Fixedsys";
private static var SIZE:Number = 12;
private static var TextFields:Array = [];
private static var trace_stage:Stage;
public static function initTrace(stg:Stage):void
{
trace_stage = stg;
trace = wtrace;
}
private static function scrollup():void
{
// maximum number of lines: 100
if (TextFields.length > 100)
{
var removeme:TextField = TextFields.shift();
trace_stage.removeChild(removeme);
removeme = null;
}
for(var x:Number=0;x<TextFields.length;x++)
{
(TextFields[x] as TextField).y -= SIZE*1.2;
}
}
public static function wtrace(... args):void
{
var s:String="";
var tracefield:TextField;
for (var i:int;i < args.length;i++)
{
// imitating flash:
// putting a space between the parameters
if (i != 0) s+=" ";
s+=args[i].toString();
}
tracefield= new TextField();
tracefield.autoSize = "left";
tracefield.text = s;
tracefield.y = trace_stage.stageHeight - 20;
var tf:TextFormat = new TextFormat(FONT, SIZE);
tracefield.setTextFormat(tf);
trace_stage.addChild(tracefield);
scrollup();
TextFields.push(tracefield);
}
}//end of trace