⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapplotterinit.as

📁 Network Management Information System
💻 AS
字号:
// test data

img="worldmap.jpg";
fgColor="0xffffff"
nodeSize = 17;
fontSize = 10;
nodeOnColor = "0x00ff00";
nodeOffColor = "0xff0000";
lineSize = 3;
topLat = 500;
topLong = 500;
botLat = 600;
botLong = 800;
legend="110;400;200;100;the key;10";
entry_1=".1;.5;0xff0000;.1 to .5";
entry_2=".5;1;0x00ff00;.6 to 1";
entry_3="2;3;0x0000ff;2 to 3";
node_1="1;550;550;1;1;http://www.chch.co.nz;1";
node_2="2;550;790;2;2;http://www.dndn.co.nz;1";
node_3="3;550;720;3;3;http://www.chch.co.nz;1";
node_4="4;550;620;4;4;http://www.dndn.co.nz;1";
node_5="5;580;550;5;5;http://www.chch.co.nz;1";
node_6="6;530;790;6;6;http://www.dndn.co.nz;1";
node_7="7;580;580;7;7;http://www.chch.co.nz;1";
node_8="8;530;740;sriodjhiosrtdjoph;1;http://www.dndn.co.nz;1";
link_1="1;3;.6;http:www.google.com";
varsLoaded = "true";



/**************************************
 * Setup
 **************************************/

// initialise variables
var param; // used in data import loop
var nodes = new Object();  // holds the nodes
var links = new Array();  // holds the links
var aEntries = new Array();  // holds the key entries
var data_array;  // used in data import loop
var obj;  // object pointer
var leg = new Object();  // the legend
var legendFormat = new TextFormat();  // text format for the legend
var nodeTextFormat = new TextFormat();  // text format for the nodes
var p1, p2, p3, p4;  // points
var img;  // the path to the image
var nodeDepth = 2000;  // the depth of the last generated node
var nodeTextDepth = 1000;
var nodeName = "node_";  // a string to generate unique names for node movie clips
var linkDepth = 1500;  // the depth of the last generated link
var linkName = "link_";  // a string to generate unique names for link movie clips
var fontPixelSize = fontSize * 1.5;  // pixel size for global fonts

// massage incoming data
nodeSize = parseInt(nodeSize);

/**************************************
 * Point class
 **************************************/
function Point(x, y){
	this.x = x;
	this.y = y;
}

/**************************************
 * Nodes
 **************************************/
 
// Node text format
with(nodeTextFormat){
	color = fgcolor;
	font = "Verdana";
	size = fontSize;
	bold = true;
}
 
 
// Node class
function Node(lat, long, label, pos, url, status){
	
	// convert lat and long into x and y
	var latRange = botLat - topLat;
	var longRange = botLong - topLong;
	var latBase = lat - topLat;
	var longBase = long - topLong;
	var latP = latBase / latRange;
	var longP = longBase / longRange;
	this.x = Stage.width * longP;
	this.y = Stage.height * latP;
	
	// other properties
	this.label = label;
	this.pos = pos;
	this.url = url;
	this.status = status;
	
	// the movie clip	
	nodeName += "a";  // make a unique name	
	_root.createEmptyMovieClip(nodeName, nodeDepth++);
	this.clip = _root[nodeName];
	this.clip.parent = this;	
	
	// register the clip as a mouse event listener
	Mouse.addListener(this.clip);
	
	// assign the event handlers
	this.clip.onRollOver = over;		
	this.clip.onRollOut = out;
	this.clip.onPress = goToURL;
} 

function over(){		
	this.parent.draw(1);
}

function out(){		
	this.parent.draw(0);
}

function goToURL(){
	getURL(this.parent.url, "_blank");
}

Node.prototype.draw = function(over){
	var col;
	if(over){
		col = fgColor;
	}
	else{
		col = this.status ? nodeOnColor : nodeOffColor;
	}
	with(this){
		clip.clear();
		
		// first the outer circle/border
		clip.moveTo(x, y);
		clip.lineStyle(nodeSize, fgColor);
		clip.lineTo(x, y+1);
		clip.lineTo(x+1, y+1);;
		clip.lineTo(x+1, y);
		clip.lineTo(x, y);
		clip.lineTo(x+1, y+1); 
		
		// then the inside bit		
		clip.moveTo(x, y);
		clip.lineStyle(nodeSize-2, col);
		clip.lineTo(x, y+1);
		clip.lineTo(x+1, y+1);;
		clip.lineTo(x+1, y);
		clip.lineTo(x, y);
		clip.lineTo(x+1, y+1); 
	}	
}

Node.prototype.drawLabel = function(){
	var theLabel;  // reference to the label
	var labelDepth = nodeTextDepth++;  // so we can use it for the label's name and guarantee uniqueness
	// create the label and reference
	
	_root.createTextField(this.label + labelDepth + "_txt", labelDepth, 1, 1, 1, 1);	
	theLabel = _root[this.label + labelDepth + "_txt"];

	with(theLabel){
		selectable = false;
		text = this.label;
		autosize = "right";
		setTextFormat(nodeTextFormat);	
		
		// work out the position for the label
		trace(this.toString());		
		switch(this.pos){
			case 1:			
				_x = this.x - (_width / 2);
				_y = this.y - (_height * 1.1);
				break;
			case 2:			
				_x = this.x + nodeSize;
				_y = this.y - (_height);
				break
			case 3:			
				_x = this.x + (nodeSize * 1);
				_y = this.y - (nodeSize);
				break;
			case 4:
				_x = this.x + (nodeSize * 1);
				_y = this.y;
				break;
			case 5:			
				_x = this.x - (_width / 2);
				_y = this.y + (_height * .1);
				break;
			case 6:								
				_x = this.x - _width;
				_y = this.y;
				break;
			case 7:			
				_x = this.x - _width - (nodeSize / 2);
				_y = this.y - nodeSize;
				break;
			case 8:			
				_x = this.x - _width - (nodeSize / 2);
				_y = this.y - _height;
				break;		
		}	
	}
}

/**************************************
 * Links
 **************************************/

// Link class
function Link(from, to, value, url){
	this.from = nodes[from];
	this.to = nodes[to];
	this.value = parseFloat(value);
	this.url = url;
	
	// work out the colour
	for(var i=0; i<aEntries.length; i++){
		if( (this.value > aEntries[i].min) && (this.value <= aEntries[i].max) ){
			this.color = aEntries[i].color;
			break;
		}
	}
	
	// the movie clip	
	linkName += "a";  // make a unique name	
	_root.createEmptyMovieClip(linkName, linkDepth++);
	this.clip = _root[linkName];
	this.clip.parent = this;	
	
	// register the clip as a mouse event listener
	Mouse.addListener(this.clip);
	
	// assign the event handlers
	this.clip.onRollOver = over;		
	this.clip.onRollOut = out;
	this.clip.onPress = goToURL;
}

Link.prototype.draw = function(over){
	var col;  // the colour of the link
	var hsize;  // the horizontal size of the link
	var mapWidth;  // the width of the map
	var leftIn;  // the leftmost link point in the map
	var rightIn;  // the rigthmost link point in the map
	var leftOut;  // the virtual point for the left
	var rightOut;  // the virtual point for the right
	if(over){
		col = fgColor;
	}
	else{
		col = this.color;
	}
	with(this){
		
		// Wrapping
		// --------
		
		// the horizontal size of the link		
		if(from.x > to.x){
			hsize = from.x - to.x;
		}
		else{
			hsize = to.x - from.x;
		}
		
		// the width of the map
		mapWidth = Stage.width;
		
		if(hsize > (mapWidth / 1.5) ){  // split the line in two - wrap it			
			if(from.x <= to.x){
				leftIn = from;
				rightIn = to;
			} 
			else{
				leftIn = to;
				rightIn = from;
			}
			
			
			// create two new points outside the boundaries of the map
			leftOut = new Point(0 - (mapWidth - rightIn.x), rightIn.y);
			rightOut = new Point(mapWidth + leftIn.x, leftIn.y);	
			
			
			// draw the two lines
			clip.clear();
			clip.lineStyle(lineSize, col);
			clip.moveTo(leftIn.x, leftIn.y);
			clip.lineTo(leftOut.x, leftOut.y);
			clip.moveTo(rightIn.x, rightIn.y);
			clip.lineTo(rightOut.x, rightOut.y);
		}
		else{	  // no need to wrap - just draw the line	
			clip.clear();
			clip.moveTo(from.x, from.y);
			clip.lineStyle(lineSize, col);
			clip.lineTo(to.x, to.y);
		}	
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -