/** December 2006 XY coord v1. Copyright © 2006 by Andrei Potorac All rights reserved. */ stop(); Stage.showMenu = false; Stage.scaleMode = "noScale"; this._lockroot = true; /******************** General settings ********************/ var nrFrames:Number = 30; var nrPlots:Number; /******************** MAP SIZE ********************/ var xwidth:Number; var yheight:Number; // /******************** MAP COORDINATES ********************/ var maxLatN:Number; var minLatS:Number; var maxLongE:Number; var minLongW:Number; // /******************** PIXEL VALUES PER DEGREE ********************/ // var xFactor:Number; var yFactor:Number; /******************** VARIABLES ********************/ var masterArray:Array = new Array(); var linkArray:Array = new Array(); var targetArray:Array = new Array(); var longitudeArray:Array = new Array(); var latitudeArray:Array = new Array(); // _root.createEmptyMovieClip("mapHolder", -1); // //************************************************************// // EFFECT: "FADE IN" AND "FADE OUT" //************************************************************// MovieClip.prototype.fade = function(dir:String, addInteger:Number, f):Void { delete this.onEnterFrame; //this.step = (dir == "in") ? 0 : 100; this.step = this._alpha; this.onEnterFrame = function():Void { this.step = (dir == "in") ? this.step+addInteger : this.step-addInteger; this._alpha = this.step; if (((dir == "in") && this._alpha>=100) || ((dir == "out") && this._alpha<=0)) { delete this.onEnterFrame; f(); } }; }; // /******************** Parse XML ********************/ // var trackXML:XML = new XML(); trackXML.ignoreWhite = true; _root.trackXML.load("settings.xml"); // trackXML.onLoad = function():Void { var currentNode:XMLNode = this.firstChild.firstChild; var i:Number = 0; for (var childNode = currentNode; childNode != null; childNode=childNode.nextSibling, i++) { var j:Number = 0; masterArray[i] = new Array(); j++; for (var stringNode = childNode.firstChild; stringNode != null; stringNode=stringNode.nextSibling, j++) { masterArray[i][j] = stringNode.firstChild.nodeValue; //trace("masterArray["+i+"]["+j+"]"+masterArray[i][j]); if (i == 0) { _root.maxLatN = stringNode.attributes.maxLatN; _root.minLatS = stringNode.attributes.minLatS; _root.maxLongE = stringNode.attributes.maxLongE; _root.minLongW = stringNode.attributes.minLongW; // } else if (i == 1) { _root.linkArray[j] = stringNode.attributes.link; _root.targetArray[j] = stringNode.attributes.target; // _root.longitudeArray[j] = stringNode.attributes.longitude; _root.latitudeArray[j] = stringNode.attributes.latitude; // } } } _root.nrPlots = masterArray[1].length-1; _root.loadPic(); }; function loadPic():Void { _root.mcLoader.fade("in", 15); _root.mapHolder.loadMovie(masterArray[0][1]); _root.mapHolder._alpha = 0; _root.mapHolder._x = 30; _root.mapHolder._y = 140; clearInterval(_root.myInterval); _root.myInterval = setInterval(checkLoadingProgress, 100); } //************************************************************// // CHECK IF THE MOVIE HAS LOADED ENTIRELY //************************************************************// function checkLoadingProgress():Void { var mc:MovieClip = _root.mapHolder; var myload:Number = mc.getBytesLoaded(); var mytotal:Number = mc.getBytesTotal(); var mypercent:Number = Math.round((myload/mytotal)*100); // mcLoader.mcBar._xscale += (mypercent-mcLoader.mcBar._xscale)/3; // if (mypercent>=100) { clearInterval(_root.myInterval); _root.mcLoader.mcBar._xscale = 100; _root.xwidth = mc._width; _root.yheight = mc._height; // mc.fade("in", 5); _root.mcLoader.fade("out", 15); _root.init(); } } // //************************************************************// // FUNCTIONS //************************************************************// function init():Void { /******************** CALCULATE PIXEL VALUES PER DEGREE --------------------------------- calculate the number of pixels per degrees of both your X and Y axis ********************/ _root.xFactor = _root.xwidth/(_root.maxLongE-_root.minLongW); _root.yFactor = _root.yheight/(_root.maxLatN-_root.minLatS); // for (i=1; i<=_root.nrPlots; i++) { _root.latToPixel(i); } } // //************************************************************// // CONSTRUCTOR FOR THE PLOT POINTS //************************************************************// function latToPixel(i):Void { // attachMovie("plotMc", "plotMc"+i, i); _root["plotMc"+i].displayMc._visible = false; // //CALCULATE THE COORDINATES IN PIXELS _root["plotMc"+i].xCoord = _root.xwidth/2-Math.floor(((_root.maxLongE-_root.longitudeArray[i])*_root.xFactor)-_root.xwidth/2); _root["plotMc"+i].yCoord = Math.floor(((_root.maxLatN-_root.latitudeArray[i])*_root.yFactor)); // //PLOT ACTIONS _root["plotMc"+i]._x = Math.abs(_root["plotMc"+i].xCoord)+30; _root["plotMc"+i]._y = Math.abs(_root["plotMc"+i].yCoord)+140; // // _root["plotMc"+i].but.onRollOver = function() { _root["plotMc"+i].displayMc.txt.htmlText = "xCoord: "+_root.longitudeArray[i]; _root["plotMc"+i].displayMc.txt.htmlText += "\n"+"yCoord: "+_root.latitudeArray[i]+"\n"+_root.masterArray[1][i]; _root["plotMc"+i].displayMc._visible = true; }; // // _root["plotMc"+i].but.onRollOut = function() { _root["plotMc"+i].displayMc.txt.htmlText = ""; _root["plotMc"+i].displayMc.txt.htmlText += ""; _root["plotMc"+i].displayMc._visible = false; }; // _root["plotMc"+i].but.onPress = function() { if (_root.linkArray[i] != undefined && _root.linkArray[i] != "") { getURL(_root.linkArray[i], _root.targetArray[i]); } }; }