Tuesday, April 21, 2009

Final Project Progress

For my final project I really wanted to make a map that would be constantly changing; Something that could, whenever it were viewed, tell you what was going on at the moment in time. With technology increasing and the availability of live feeds from so many sources, this seemed like a great idea.

I ended up deciding to use the feeds from the USGS to map earthquake data around the world. Its very impressive actually see the amount of earthquakes we have in the US daily, even though most go unnoticed and not felt.

To view the data I'm using, click HERE to view 1 days data, and HERE to view a weeks worth.

Now some example code and explanation of it:
---------------------------------------------------------------
  1. var url:String="http://earthquake.usgs.gov/eqcenter/catalogs/eqs1day-M1.txt";
  2. var usgsDataLoader:URLLoader = new URLLoader();
  3. usgsDataLoader.addEventListener(Event.COMPLETE, textLoaded);
  4. usgsDataLoader.load(new URLRequest(url));
  5. function textLoaded(event:Event):void {
  6. var usgsDataDay:String=event.target.data as String;
  7. }
---------------------------------------------------------------
Line 1 makes a new variable called url which contains the location to the data file we are trying to fetch and read.
Line 2 creates a new url loader - this will read information from a URL and load it into flash.
In line 3, we add an event listener to our url loader - once the URL is loaded into flash, the function "textLoaded" is run.
We finally load our usgsDataLoader variable with the info from our URL.
upon completion of loading our data, we call our textloaded function and make a new variable of type string which holds the data from our loader

There you have it...how to load external data into flash. Although we now have our data loaded into flash, there is alot we have to do before we can actually make use of it such as parsing and splitting it up or searching through our text to find parts of interest, and even more work before we can incorporate it into our FLASH ide, making information in the text actually affect something in our flash movie.

If you have any questions on how this code works feel free to post up.

No comments:

Post a Comment