Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Once the ActionScript structure of a basic button is in place, I can now navigate to this section selected, because currently what's going on, if I go to Control>Test Movie, all I have are these various trace statements that are being shown in the Output panel. But what I want to happen is I want to actually navigate to the video section when I click on the Video button and likewise for all the other buttons. So let's take a look at the code.
I'm going to go to the AS layer. I'm going to select that first frame. I'm going to go Window and open up the Actions panel and the first thing I'm going to do is I'm going to pin the code, because, again, I don't want it to move if I click on something else. I want it to always stay up and available. But as you can see, when you click on the home button, all I get is the trace statement and same for the about button and the video button. Now, I'm just going to go ahead and start with the Video button and what you can do is click in this gray bar.
You can just retract the Actions panel, so it's out of the way. I am going to Command+Minus to zoom out. I want to move this content movie clip this direction, and I want to change the X and Y position of this content and see. It starts out. Again, I'm going to do an Undo Move. It's going to start here and then I want it to end up right here. So let's go ahead and reference the X and Y position.
So in the Properties panel, with the content movie clip selected, I can see that the Position and Size, the X is -920. In fact, I'll just round that to 920 and then the Y is about 530, maybe I want to make it about 520 or let's go 540, have it move up a little bit just so we can make sure we get that Portfolio button down there. That's a pretty good position, -920 by -550 for the Y position and that's what I want to move the content_mc to.
So I'm going to open up my Actions panel that was currently nested. And I'm going to go to the video button and when it's clicked on, it's going to fire off this function and then just below the trace statement, you can type in 'content_mc' and then change, after I type that period, I can change the property of this movie clip and I want to change the x position. Okay, so this is going to be horizontally that it's going to move. So change the x position equal to -920, just like it shows right over here.
The y position, -550. New line, content_mc.y equals, again, don't forget the -550, just like that. So again, I'm going to click on this gray bar just to nest the Actions panel into that one bar and I'm going to go ahead and move this back into position. Now, I could kind of eyeball this, but what I'd like to do is use the Align panel. So I'm going to go to Window > Align and make sure this button is depressed, the To-stage button, and I want to center vertically and horizontally to make sure that is in its exact position.
Now, this is the starting point. So the John Doe button, it's the home button, and when you click on his name, I want to reset the position of the content_mc, back to this location, which is -600 x -752. So I'm going to remember those numbers because when I click on the home button, I want to adjust the x and y position of content_mc. Again, x position is going to be equal to -600 and content_mc's y position is going to be equal to -752.
Now, I'm just going to round that to a whole number, -752, and with the home button set up and the video button set up, it should work just fine. So I'm just going to go ahead and check syntax by clicking that check box and this script contains no errors. Now, let's go ahead and do the Control > Test Movie. I'll move this into place and now when I click on video, it pops, changes the x and y position, when I click on that video_btn and then for the home button, bam, snaps back into place.
So it's working quite well, and quite frankly, I can set up the other two now. So let's close this and go back into my code and I can start to add some of the code for the other buttons. So let's go ahead and minimize this Actions panel and what I want to do now is bring in the about section. Now the About section is actually going to rotate. So I need to do just kind of minimize, scoot this out of the way. I want to expand out this panel and I just want to be able to see the Transform panel, because what I need to do is I need to change the rotation of this content_mc.
And what I can do is is I can just go ahead and click and drag and I can see that rotate around. Now, you can use the Transform panel to, obviously, transform anything. I could even use, in my Tools panel, the Free Transform tool, in case I just kind of want to adjust it this way. But I think when you're dealing with code it's better to do it numerically, so that's why I'm going to use the Transform panel, just to rotate it a -90 degrees, just like that.
So I'll just position it into place. Use my arrow keys to fine-tune it like that. That's a pretty good position. All right. It's a -90 degrees is the rotation. The x and y position, and I'll just round this up, is going to be -250 and a positive 1430, just like that. All right. I'm going to remember those numbers and the 90 degrees when I open up my Actions panel and again, this is for the about button.
Make sure you're inside of this aboutClick function. So just before this closing curly brace, you can type in content_mc, move its x position to -250, its y position 1430, _mc rotation, well, I will just start to type in 'rotate.' Oh! Rotation, there it is. I can select it, hit return, and then make that equal to -90 degrees.
Now, there is an issue, because I'm dealing with rotation at this point and these other two are not rotating. In fact, I need to make sure the rotation gets set back to zero for these other two. So I'm just going to go ahead and copy this. I'm going to select it and copy that line of code and paste it right into the home button's function and I'm going to make sure the rotation gets set back to 0. Same thing for the video button, paste that in there, set the rotation back to 0.
All right. It's looking pretty good so far. In fact, I'm just going to go ahead and do the Portfolio button now as well. So let's see what that looks like. Portfolio button actually shifts over and is really going to be on the same y-axis, but the x axis is going to change. So I'm just going to position that accordingly, maybe use my arrow keys to fine tune it. In the Properties panel, maybe make it -1000 and then this is going to be 1450.
All right. So I'm going to open up my Actions panel for the Portfolio button and again, I can just copy all of the x and y rotation from a previous function and paste it in and start changing some of these numbers. As for the Portfolio button, it's going to move to the left -1000 and then the y is going to be 1450 and let's be aware that the rotation is still -90 degrees, so -90.
All right. Everything seems to be looking pretty good, but you never know until you test it. So I'll do a Control > Test Movie. And as you can see, I didn't move it back to its original place when I finished getting all my coordinates. So I can go ahead and fix that just by typing in 0 here. Change the Align panel. Change the Align horizontal center and the vertical center to reset it back to its original position.
Now, Control > Test Movie. It's in its original position. I'm going to go ahead and click About. I can see that it rotates and then moves the x and y position, and go to Video and I can even go to Portfolio. So it's looking pretty good so far. I can select any one of these and I can even reset back to the beginning, just like that, by clicking John Doe. So notice that as I select the button, it changes the properties for the content movie clip to reveal that section.
Get unlimited access to all courses for just $25/month.Become a member