Click on any phrase to play the video from that point.
[♪ fast music ♪] [Adobe TV Presents Paul Trani in...]
[Flash Training with Paul Trani]
[♪ upbeat music ♪]
Hi, my name is Paul Trani, evangelist for Adobe,
and what you can do with GPS data is do more
than just get your X and Y coordinates if you will,
your GPS horizontal and vertical coordinates.
You can actually get the speed of items, and
that's what I'm going to do, I'm going to show you some of
these additional properties you can get with the geolocation class.
So here I have this simple app, "Ready to Run?" is what it's called,
and basically it will get how fast you run
during a certain set amount of time,
and really what you do is you hit start, and
it will get your meters per second
and then convert that to miles per hour,
and it will get your highest number that you run
before you hit the stop button, and then
shows you a result screen.
So what I want to do is I want to go ahead and get
my speed based on geolocation data.
So I'm going into the code snippets, and
I'm selecting show geolocation,
and what I can do is just double click that
code snippet to add it right in here,
and it does ask me to enable access find location,
and access course location in the permissions dialogue box.
So I can go ahead and do that.
In fact, let me pin my code
so it doesn't move, and I'll jump out here
to my application settings.
Everything looks pretty good, but
if I go into permissions right here, access find and course locations.
So this does it based on cell towers.
This one actually does it using GPS data.
Okay, so that's how I'm going to determine
sort of where I am, and I'm able to access additional properties,
but the properties I want to access are going to be this speed,
but let's take a look at this geolocation class,
and I'll just take a look at some of what's being created here.
It actually just creates a text field and then displays text,
and I really don't want to do that.
I'm going to get rid of most of that code.
In fact, what I want to isolate is just this function
and some of these properties as well.
So there's a variable that's created called geolocation 2,
set requested update interval.
This is--determines how often this gets updated.
The latitude, longitude, or the speed,
and, again, it's set at 1 second.
All right, so every second it checks to see if there's an update,
and if there is, you can go ahead and get the latitude, longitude, or the altitude.
So I actually don't want to get any of these things,
I want to get the speed.
So in order to do that, what I'm going to do is
I'm going to create a new variable,
and that variable is called miles per second, okay?
MPS.
So that's where the new variable is created.
I'll get rid of most of this code,
and I'll say, "MPS is equal to event dot speed."
Okay, so just like we have event dot latitude,
I have event dot speed right here.
Okay, so I can get rid of that.
Again, I can get the speed; it can be the latitude, the longitude, the horizontal accuracy,
the vertical accuracy, and what I'm going to do with that variable
that contains the speed data is
I'm going to go ahead and put it in the run movie clip.
Inside of the run movie clip is the miles per second, or excuse me,
the meters per second text field, and
inside of that text field, we're going to go ahead and add the meters per second
with some additional data just like that.
All right, there we are.
So whatever the speed is go ahead and drop it in this text field,
and display it, but I want to go ahead and
take that meters per second, and I want to convert it
to miles per hour,
and in order to do that, what I can do is
I can go ahead and have a new variable right up here.
It's called current miles per hour.
I'll just copy that.
Current miles per hour
is equal to the meters per second,
and if I just do a quick search in Google,
you'll see that the meters per second to miles per hour ratio
is 1 to 2.23, this number right here.
So that's the number I'm going go ahead and copy.
Okay, so Google did the conversion for me and that's great.
I'll just take that number, copy it, go in here,
take the meters per second and multiply it by that amount,
just like that.
All right, so it's going to give me not a whole number,
and I want it to--I want to round this number to a whole number.
So I'm going to say, "Math dot round," and
it'll round it up or down to the nearest whole integer.
All right, lastly,
I can say, "If current MPH is greater than the max MPH,
maximum miles per hour, which is set to 0 initially,
if it's greater than 0,
then go ahead and change the max miles per hour
and make it equal to the current miles per hour.
So hopefully that makes sense.
Anytime you beat a previous sort of high speed,
then it will change your maximum miles per hour,
and that's all I'm doing there.
Again, event dot speed, this is the property
that you're getting of the geolocation class.
There's other properties as well, but this is one easy way
you can take some code to actually turn into a nice app.
So I'd say this is good to go, keep in mind I do have
to maintain that speed for at least 1 second,
but basically I have this running app.
Again, meters per second goes in here.
My miles per hour goes right here, and
with all of that set up, I can go ahead and go into my publish settings.
Everything looks good here, and with my Android device connected,
and, again, it could be an iOS device,
just hit publish, and it'll put it on my device.
All right, so here's my Android phone.
Let me disconnect it here, and
sure enough, you can tell here's my app "Ready to Run?"
I think that sounds like a good idea; I'll click start.
Obviously, I'm going 0 miles per hour.
That will adjust, but in general what I need to do
now is go ahead and go for a quick run, and when I'm done, I'll hit stop.
So I'm going to go ahead and take off right now,
and I'll be back hopefully pretty fast.
[♪ upbeat music ♪]
All right, I'm actually back from my run.
Let's see how fast I went, and, again,
I've already hit stop as you can tell.
This is the result screen.
Your fastest time was 7 miles per hour.
You can run as fast as a hippo.
So I feel pretty lazy at this point, but then
nonetheless, it is actually tracking that data.
I think I ran for only like a 20-second sprint,
but even with that data, you can do this over time,
so your average speed was this, your fastest time was this,
your slowest time--whatever you want to do,
but, again, it's all using geolocation,
and, of course, flash to display the data.
So try it out for yourself,
have fun with it, and thanks so much for watching.
[♪ upbeat music ♪]
[Executive Producer Bob Donlon, Producer Karl Miller, Director/VFX Kush Amerasinghe]
[DP/Post Production Erik Espera, Adobe TV Productions, tv.adobe.com]

