Now, we are ready to start working on some of the buttons for our slides. Up to this point, we have used a lot of movie clip properties and screen properties to get a lot of reusability out of our interface so far and now, I am ready to go back into a little bit more action script. We are going to be making the button set. So, let us go down to our main menu or got our buttoned bar built in here, and what I would like to do is I would like to build up a generic button that we can reuse that is based on action script. So, let us take that field that we have started with for a place holder for a button.
Now, I am going to leave it just as it is and there is a couple of things that I want to make sure I set up because it will make sure that this buttons will work later. The first thing that will help out a little bit is if the button is center aligned because we are going to be using the positioning of that center point to be able to make sure that this works properly. Also, I am going to change it from a static text field to a dynamic text field. Now, that will open it up for action script, so, we should go ahead and give it a name right away, I will call it TXT label because we are going to use this as a button label. Now, I am also going to change one more property that we could change with action script but I might as well do it while we were here. That is this button right down here controls whether the text is selectable or not.
Now, since we are going to have this thing act as a button, I really do not want an eye bar cursor popping out for users. I am going to turn that off. Now, we got a text field here but to make it act like a button, what I am going to do is in case this inside of a movie clip. We are not going to use a real button symbol at this point, we are going to use a movie clip symbol and we are going to write the action script ourselves. So, I am going to press F8 when we have it selected. I will call this generic button and I am also going to center the registration before we make that.
So now, we have a movie clip here with our dynamic text field called text label inside of it. Now, I am going to be pulling a lot of this ad on to the stage to use for all of my different buttons. So, in order to make sure that some of the action script comes with each one of the button elements, I am going to place the first piece of action script right inside of this movie clip itself. Now, let us see, I am going to put this over here on the front part of my button bar and this is going to eventually be my home button, so, I am just going to call this one home.
Now, I am going away from my naming conventions here a little bit but there is a purpose involved and I will point out that we are using home for the name and home is going to be the name of the screen that is going to navigate to and home is what I like to say on the button. So, let us see how we can use action script to achieve all of those results for us.
I am going to go up to the button itself. I will double click on it and you see there we are inside the button, I have just got that text field right there in layer one. Let us add a layer or action script and let us write a little bit of action script for this. I am going to click on that key frame in the first layer. I will bring up my actions window with option F9 or F9 on the PC and let us start some things out.
Now, we have messed with a lot of properties of text fields and one of that we are playing with is the name of the text field itself. I will just do a quick trace and we will trace this, remember that keyword that points back to the object that we are talking about in this case the movie clip and I will just use .syntax to access the underscore name property.
Now, if we test our movie, out buttons are on the screen right at the beginning of the movie, so we should see our trace statement popup and it tells me that the name of the button is called home. Well, I can pull the name off the button and using that, I can apply it some place just like we would a normal variable or a string value. So, let us close this down and using that fact, what I would like to do is take the text field sitting inside of here, that one is called TXT label. It has a text property of course and we will set that equal to this ._name. Basically, what I am going to achieve here is I am going to have the button label itself, test our movie.
Now, it is not button, it is home. So, taking an advantage of that, I can toss a few more buttons out on the screen. Let me get my action script out of the way and I will just pull out a couple of more generic buttons or better yet I will just grab it right here on the screen now. I will go back out to main menu, I will grab that movie clip called home that we started off with and I will just use option drag to make copies. I might as well go ahead and copy the rest of them since we are working on this. I need six buttons total, so, I just make six copies here and since each one of the buttons is going to be based on the name of the button itself. Let us go ahead and change those from home since we copied them all at the same name to the names of the rest of the buttons. We are going to need about button next followed by, let us see, I think we got some reference over here in our text field. I think services was next, that is right. Let us change this one to services. We got a clients button, one for press and one for contact.
We will do a quick test and I think you know what we are going to get. We have now got all of the buttons dropped in here.
Transcription by:
Scribe4you Transcription Services