Graphics Programs Reference
In-Depth Information
var p:Point;
for (var i:int = 0; i < locations.length; i++) {
p = map.locationPoint(locations[i], this);
xpoints[i] = p.x;
ypoints[i] = p.y;
}
}
The second function, setMarkers() , uses the points that setPoints() stores
and places markers accordingly.
protected function setMarkers():void
{
markers = new Array();
for (var i:int = 0; i < locations.length; i++)
{
var marker:Marker = new Marker();
addChild(marker);
marker.x = xpoints[i]; marker.y = ypoints[i];
markers.push(marker);
}
}
The function also uses a custom Marker class, which you can find in
com ➪ flowingdata ➪ gps ➪ Marker.as, assuming you have downloaded
the complete source code. It's basically a holder, and when you call its
play() function, it “lights up.”
Now you have location and markers loaded on the map. However, if you
compiled the code now and played the file, you would still see a blank map.
The next step is to cycle through the markers to make them light up at the
right time.
The playNextStore() function simply calls play() of the next marker and
then gets ready to play the one after that. The startAnimation() and
onNextYear() functions use timers to incrementally display each store.
private function playNextStore(e:TimerEvent):void
{
Marker(markers[markerIndex]).play();
markerIndex++;
}
Search WWH ::




Custom Search