Setting the Date
Lets see how we can set our date using the global milliseconds we learned of in the last video.
Video Transcript
00:01All right, so we're back in flash flash and let's see the next steps that we need to do
00:05So we know that we need to we need to capture the amount of milliseconds that pass since that odd date back in back in the
00:12Days, all right
00:13So the next step that we actually want to do is we want to actually just create some sort of because we want to use that
00:19Time that's coming from that HTML file
00:21But when we're running water when we're running it inside of flash
00:25The value that we're getting back is undefined because that value is not in there
00:29So we're going to use one thing that we know what urinary operations
00:34That we know from
00:36previous courses, so we're going to create your variable called time which is going to be an integer and
00:42We are going to ask if this variable exists if this value is in there
00:47We're gonna ask if that's a ternary if then we will paste that value will put that value into our temp time
00:54integer if not
00:55We're gonna put in our new value which is going to be a different value and that value is going to sound very odd
01:01But I already calculated earlier which is one three zero six zero nine seven
01:09zero five one six one three and I have your little sticky note that let me know that and that's amount of time that passed since
01:16We actually wanted to time the time to begin now because this is kind of a stitch
01:21We had a little bit issue in our live recording
01:23This is not our actual time while we're doing the recording, but I want to show you how actually
01:29This fix that we're going we're doing right now
01:31So if I wanted to I just want to show you how to build that object as if we're getting we're doing this little
01:36Stitch we're doing this little fix between our live event and this
01:39Recorded post event because the recording didn't come out that well, so let's look at this
01:44So I'm gonna create a new variable and I'm gonna call it date now again
01:48The time that's coming back is that integer value which is the number that's going to represent the amount of time that passed
01:53Since our time actually started so our date is going to be a date type and we're going to type a new date
01:59And we're not going to put anything inside of it in the beginning and we're just going to trace out the current date
02:05By just tracing out our current date
02:07We're going to get the current time and date of when this recording is being done
02:10So you can see that right now. It's quite late at night, and we're doing our first
02:15Tweak to our our live event a couple of hours later now
02:19If we wanted to see the amount of time that passed in milliseconds
02:22All we have to do is type date that time like we saw in that HTML and then instead of that
02:27We're gonna get this value and this value is going to be the current time
02:31But we already know that our current time is much much later than that now deliberate
02:36Deliberately, I have your small little error that we're gonna catch later on in the live event
02:40And I wanted deliberately to leave it there because I wanted us to see that error and
02:45See how we fix it together, and now we find the issue and how we deal with it
02:49All right, so we're in the stage where we already have our time
02:54We now just need to figure out how to actually output this onto the display
02:58So we already seen that using our new date object, and we could have created a new date object
03:04We could then just like as we created the time right and now we don't need it anymore because you already grabbed it earlier on
03:11We could even we could now trace out our current time now notice how now the time is a little bit later because we had a
03:18Break now. It's a May 22nd 502
03:21But look what happens if we just take that time that we've just created and put it in as the first parameter as the of
03:26The new date now when the new date will be created
03:30And you know let me just do this
03:32We're just gonna do it right after so I'm gonna do date equals new
03:36Date so we could see the difference and this time around we're gonna put in that time
03:41And then we're gonna trace out the date and if we run our application one more time
03:45We'll see that our original time that we posted our things did not change
03:50Or did it GMT minus 5 why would it be minus 5?
03:57Should be minus 4 as well
04:02Then we just found here a little oh probably the value that I put in here is invalid
04:07So let's let's just make sure that I didn't put a value that wasn't valid
04:11So I'm just gonna type here again the date that time just for a second
04:15I just I'm gonna copy a time so that would be you see okay, so the value see the value that's coming back here
04:21It's the 42 that's not the right value. We need the value to be 13 million blah blah blah blah our int value though
04:29Just probably isn't good enough
04:31so
04:32What would happen if we change this into a number?
04:36We'll see that we're getting that value and the reason is just the end just doesn't have enough
04:41There's just isn't enough room in the int type because the int type
04:46Just doesn't have as much room as the number type does all right
04:49So if we if we just just explain this really really quickly if I just create a renewed time
04:56ends and
04:57I just said it directly without all this if statements
04:59I put it here this really really big number and as soon as I trace out this big number
05:03It's gonna automatically truncate it because this number doesn't exist in integers the biggest number in an integer is actually
05:10int dot max value
05:13the biggest number in an integer is
05:16that value and
05:18That value is smaller than this value, okay?
05:22But number on the other hand when you use the number the number has a lot bigger range
05:27The number has a lot a lot of range
05:28So we could then just use the number because the number has a lot more memory
05:32And uses much more memory so you could store much more into its location
05:36So that's how we solve this issue with the integer because it was giving us a completely wrong time
05:40So just by sending it back into number. We found our issue
05:44And we could undo this as well again, and just test it out one more time
05:49And if we test it out one more time. We're gonna see that originally when we started our
05:54Time class thingy the time was 444. That's supposedly the time of our event
06:00Well now the time is much later than that
06:02But even though we could have created a new date just by passing that time information and that time information is coming
06:07Externally whenever we run it in HTML
