Centering Our Timer
Our timer is starting to shape up but it's not centered. Let's see how we can fix that.
Video Transcript
00:00And this is working perfectly.
00:01The only problem is that our copy is getting
00:03shifted up and down.
00:04And what I really would want is just
00:06keeping everything somewhat somewhere in the center.
00:09To do that, for me to be able to do that,
00:11all I really have to do is connect
00:13into something a small little something we didn't really
00:15learn about yet.
00:16But we'll learn now because it's a small little feature.
00:20And to connect it, I decided that my timeout display
00:23is really only going to be used for the sample.
00:26And because of that, I really don't
00:28need to worry too much about making this reusable
00:31for other applications.
00:32Because I know exactly the behavior I want it to have.
00:36And I could go forward with it.
00:37And under that assumption, we're going
00:39to put all of our logic in here instead of inside
00:41of our main app.
00:42Because I basically just want to be
00:44able to use the exact same features and functionality
00:46over and over.
00:47I might change the look and feel of it.
00:50But that's all I would change.
00:51So if I wanted to, I could change the look and feel
00:53to give every course maybe a different color if I wanted to.
00:55Or a little bit different layout.
00:58Different font, different rendering, and so forth.
01:02So what I wanted to do is just focus for a second
01:04on our text property.
01:06And when we're looking at our text field itself
01:09and we go into our properties, we're
01:10going to see that our text field, its height is 89 pixels.
01:15Its position right now is minus 44.
01:19Why is it minus 44?
01:20Because our 0, 0 of our MC timeout movie
01:24clip is exactly in the center.
01:27Thus, we wanted our text field to be basically half
01:29of what it was before.
01:31Now, these values probably should be rounded up.
01:33It's always good to work in Flash with round numbers,
01:36but we're not going to worry about that right now.
01:38But instead of that, we're going
01:40to jump into our timeout display
01:41and go directly and work on it now
01:43that we know how our layout is working.
01:45We know that every time our time or change
01:47is an opportunity to change the layout.
01:51Knowing that that's the case after we change our copy,
01:53what I want to do is I want to ask my copy,
01:56how big is it?
01:57Now, if I just ask my time and I just ask for my height,
02:02then my height won't really give me anything
02:04because it's going to give me a consistent same height, which
02:06was that 80 something that we've seen earlier.
02:08What I actually want to ask for is
02:10a property of the text field which is called text height.
02:13And text height will give me the height of the text
02:15itself that's inside of my text field.
02:17So 84 will give me now because it's two lines.
02:20I'm getting 84.
02:22But as soon as we drop down to one line,
02:24you'll see that we have here 42.
02:27Now, you might have noticed that this 42 value almost
02:30correlates with the value in our properties panel, which
02:33was 44 and something.
02:36Now, that extra data, that extra two pixels and a bit,
02:41are really connected to the fact
02:42that our copy is not everything that we have in a text field.
02:45There's also a spacing between our copy.
02:48So there's this spacing on the top
02:49and there's a spacing on the bottom.
02:51And that spacing counts for measurement as well.
02:55But we don't really care about that spacing that much.
02:57And the reason we don't care about that spacing
02:59is we're not aligning the whole text field
03:01based on the text field.
03:03We're going to align the text field based on this copy.
03:07Now, if we're going to an assumption that we're in,
03:09we could always modify this.
03:11And obviously, if it doesn't look like it's centered
03:13or we could always add those two pixels for margin
03:16if we wanted to, but we don't really care about them.
03:18And if we will, we could always modify them
03:20and add them in.
03:22So what I want to do is I want to take that value
03:24that we just got back in our timeout display.
03:26And what I want to do is I want to take that value
03:28and divide it by minus two, because I
03:30want to go to half the size of my text field,
03:33of my text itself, minus two.
03:36Well, half the size in a negative way.
03:39And this value we could assign directly
03:41to our y-coordinate.
03:43By setting it directly to our y-coordinate, what we're doing
03:46is we're making sure that based on the size of our text field,
03:49our copy is always going to be aligned in the center.
03:53Now, if you're feeling unhappy with this
03:54and you feel like it should be two pixels up,
03:56then you could go and add another minus two,
04:00and making it more closely resemble
04:02into how it worked in editing mode.
04:05But from my perspective, I don't see a big difference
04:08between them, so I'm not too worried about it.
