flash actionscript:
I'm creating a little app that maps out the vectors of hurricanes based on data
in an XML file.
So far I've been successful with getting the app to dynamically create a movie
clip for each storm and draw a vector for each storm clip.
Going a step further, I'm trying to make it so when a user clicks on one of
the displayed storms, the storm is redrawn segment by segment with data for
each segment attached to the segment (data like wind speed, pressure, long.,
lat., time, etc.) I figured I would handle this by creating a new movie clip
for each segment and store an array for each segment within each clip.
I've set up some code that creates the movie clip, attaches the array, sets
the start point of each segment, looks ahead one data set to get the end point
for the section, and draws the line based on that.
However, when I run the app, what I get is a line that stretches diagonally
across the screen, seeming to not adhere to any of the coordinates.
Take a look. Thanks.
function showOneStorm(strmID):Void {
killAllStorms(); //removes movie clips of all storm vectors
var objStorm:Object = data.childNodes[strmID];
var stormName:String = objStorm.attributes.name;
_global.numSegments = objStorm.childNodes.length; //global var created to
feed to the killAllSegments function when going back to view all storm vectors
for (i=0; i<numSegments; i++) {
var objDataPoint:Object = objStorm.childNodes[i]; //shorten XML calls
//create vars for each segment below
var tname:String = objDataPoint.attributes.tname;
var ttime:String = objDataPoint.attributes.ttime;
var long:Number = objDataPoint.attributes.lat;
var lat:Number = objDataPoint.attributes.long;
var wind:Number = objDataPoint.attributes.wind;
var pres:Number = objDataPoint.attributes.pres;
var segmentID:String = "segment"+i; //create name for each segment movie
clip
//trace(segmentID); RETURNS CORRECT INFO
this.createEmptyMovieClip(segmentID, this.getNextHighestDepth());
this[segmentID].segmentInfo = Array(tname, ttime, long, lat, wind, pres);
//put vars into array inside each segment clip
//trace(this[segmentID].segmentInfo[0]); RETURNS CORRECT INFO
this[segmentID].lineStyle(windSize(wind), windColor(wind), 90); //set style
based on wind speed
//trace(long+"/"+lat+" startpt"); RETURNS CORRECT INFO
this[segmentID].moveTo(calcX(long), calcY(lat)); //create start point for
segment based on degree to pixel conversion
var nextpt:Number = i+1; //assign next point
var nextDataPoint:Object = objStorm.childNodes[nextpt];
var nextLong:Number = nextDataPoint.attributes.lat;
var nextLat:Number = nextDataPoint.attributes.long;
//trace(nextLong+"/"+nextLat+" endpt"); RETURNS CORRECT INFO
this[segmentID].lineTo(calcX(nextLong), calcY(nextLat)); //create line to
next point based on degree to pixel conversion
}
}