Topic: Pseudo-live Airplane tracking with Flash

So here's my idea.

I work for a big-shot evangelist who travels every week via airplane. We keep databases of his departure/arrival cities and times. From this information, I could actually develop a flash app that animates showing a "live" view of where the airplane is based upon the data we have in our database.

For instance:

I would have a jpeg of the USA which coordinates of the major cities, ie (523x712) representing Phoenix, AZ.
I would have a second coordinate, ie (1023x740) representing Pensacola, FL.
I would have the Phoenix departure time, 12:50pm and the Pensacola arrival time, 5:15pm.

From this information alone, couldn't I represent (somewhat) an airplane flying over the jpeg from one set of coordinates to the other, in the speed needed to make it arrive at the proper clock-time as my boss's arrival time?

Any thoughts from you ActionScript guru's would help smile


2 Corinthians 10:5

Re: Pseudo-live Airplane tracking with Flash

Well, I'm not quite an ActionScript "guru" but I can probably help you out with this one.  You would need to use the LoadVars object to load data into your form (if you don't know how to do that, check the help in Flash, it shoudl be enough - not difficult at all to use).  Once you have your information from the database, it'll just be some fairly simple math to get things figured out.

function get_current_plane_position() {
  // Code to pull the info into several variables
  var departure_city = Array(523,712);
  var arrival_city = Array(1023,740);
  var time_difference = 15900; // Seconds between departure time and arrival time
  var cur_time = 2500; // Current time in seconds since the departure time

  // a^2 + b^2 = c^2
  var distance = Math.sqrt(Math.pow(departure_city[0] - arrival_city[0],2) + Math.pow(departure_city[1] - arrival_city[1],2);
  var units_per_time = distance / time_difference;

  var current_distance = units_per_time * cur_time;
  var current_coordiantes = new Array(2);
  var angle = Math.asin((arrival_city[1] - departure_city[1]) / distance );
  current_coordiantes[0] = Math.cos(angle) * current_distance;
  current_coordiantes[1] = Math.sin(angle) * current_distance;
  return ( current_cooridnates);

That should (if I got al my math correct - it's really late here) return an Array with the x and y coordiantes that you need.  Your job is just getting the values to the actionscript.  Getting the time in seconds shouldn't be a big deal, most databases have function that will allow you to calculate stuff like that.

"Take up your cross before your crown" ::

Re: Pseudo-live Airplane tracking with Flash

By the way, this is an interesting resource: Flight Aware

"I was blind, but now I see!"  John 9:25