Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Adding button functionality

Adding button functionality provides you with in-depth training on Web. Taught by Paul Trani as part… Show More

Creating a First Web Site with Flash Professional CS5

with Paul Trani

Video: Adding button functionality

Adding button functionality provides you with in-depth training on Web. Taught by Paul Trani as part of the Creating a First Web Site with Flash Professional CS5
please wait ...
Adding button functionality
Video Duration: 10m 15s 2h 45m Beginner


Adding button functionality provides you with in-depth training on Web. Taught by Paul Trani as part of the Creating a First Web Site with Flash Professional CS5

View Course Description

Creating a First Web Site with Flash Professional CS5 shows how to make a fully functional, dynamic web site in Flash Professional CS5. This course covers the fundamentals of creating and importing content, adding smooth 2D and 3D transitions, and adding button functionality that goes beyond links. This course will also show how to integrate and control video and audio as well as how to implement a gallery and a contact form. Exercise files are included with the course.

Topics include:
  • Understanding web design
  • Creating buttons and web graphics in Photoshop
  • Formatting text with the Text Layout Framework
  • Using the Timeline
  • Creating a custom looping animation
  • Loading images in a gallery
  • Creating invisible buttons
  • Adding music and video to a site
  • Customizing video playback controls
  • Optimizing and publishing a web site
Flash Professional Illustrator

Adding button functionality

Essential to any site is the need to add button functionality, which will really enable that user to navigate the site and control contents. So this site is no different, because I do have all these sections set up. So what I want to do is I want to control the Timeline. And I want it to, when you click on any one of these buttons, it will jump to the appropriate section. So the first thing I need to do is I need to stop the Timeline at about Frame 29, because currently it's going to play through all over this content.

So about at Frame 29, this is where I want the Timeline to stop. And this is going to take ActionScript, okay. Luckily, what's available in Flash CS5 is code snippets. So under Window > Code Snippets, I am able to open up this Code Snippets panel. Very powerful, just really helpful in adding interactivity. But I'm going to go ahead and just put this on the side. This is actually loaded, full of ActionScript code.

And I encourage you to check out all of these different folders, because you have general actions. You can control the Timeline. You have animation controls. You can load and unload content, you know SWF files, JPEGs, audio and video as well and even some generic event handlers. But what I'm going to do is I'm just going to open up this Actions panel, just to kind of give you a quick preview. A popular one on this folder is clicking to Go to a web page, but Timeline Navigation is what I want to focus on, because again, at Frame 29, I want to stop at that frame.

So all I need to do is go to the frame I want to stop the Timeline at and double-click on that code snippet. It automatically adds that code snippet. Here it is. This is actual code that does although work, but it also gives you a comment right here, which tells you what is going on. So this is perfect. I can learn and then also see the code and even modify it. I know this is really just a really simple example, but you'd be surprised at how often you'll end up using this stop action right here.

Okay, well, where did I put this stop action? Well, down here it tells me it actually creates this Actions layer and in Frame 29 is where this code exists. So let's take a look at that. I'm going to close my Actions panel. And I'll scroll up to the top. And look at that. There it is, the Actions layer, Frame 29, right there. See that little A right there. That little A says that there are some ActionScript associated to that frame. So I can go to Window > Actions.

And there's my code. Okay, so I have actually stopped the Timeline at this point, but what I want to do next is I want to add functionality to these buttons. Now I'm not going to do that at Frame 29. What I'm going to do is I'm going to do that at Frame 1, okay. So right here at this very first frame, in case the user wants to jump directly to the Contact section, they don't have to wait for this animation to play. So it's all about usability here. One key thing to note is to make sure your graphics exist at the point in time that you apply your actions.

Okay, so again, I want to go ahead and apply some code to each one of these four buttons. And if I go to my Properties panel, and with this button selected, well, let's take a look at it. It's just an instance of the generic button. And in fact there are four of them. So I need to give each one a unique name in order to apply some code to it. I first need to give it a unique instance name. So right up here in my Properties panel, I'm going to give this an instance name of about_btn, just like that.

Now the ActionScript code I apply to the button is going to recognize this as that unique button, but I'm going to go through for each one of these and give each one an instance name, a unique name that clearly defines it. portfolio_btn. Don't use any spaces. Don't start with any special characters or numbers, just to keep it simple. contact_btn, just like that.

So each one of these buttons has an instance name. Now I can apply code to it. All right, so with this button selected, I can go to my Code Snippets panel. And in my Timeline Navigation folder, I can Click to Go to Frame and Play. And that's what I want to do. I actually want to, if I expand up this Timeline more, I'm just going to close this up actually. I want to go to Frame 30, right here. And I want to play it.

And it's going to play through and then right there. But I don't want it play through into the other sections. So again, what I need to do is add some other stop actions. So I'm going to stop at this frame here. It adds the code at Frame 49, as it shows me there. Close that, kind of move on down, right here also for the Portfolio section. Double-click and stop at this frame. And then lastly for the Contact section, I want to double-click on that code snippet to stop it at that frame.

All right, so my stop actions are in place. And again, if I go back here to my very first frame and select that button, I can select Click to Go to Frame and Play. So I'm going to ahead and apply it to that selected button, just by double-clicking on it. And it adds that code to it. Remember, it adds at this very first frame. That's what that little A is. So at the very beginning of this web site is where all my major code is going to live.

So again, here is my code, and I can start to modify it or whatever I need to do. First thing I'm going to do is I'm going to remove this panel off to the side just by clicking that left arrow. There we go. And now I can read this clear, because this comment not only tells me what it does; it gives me instructions on how to modify it. So I need to replace the number 5 with the frame number you want to jump to. Okay, in this case, it's going to be Frame 30, because Frame 30 is where that About content starts to roll in.

All right, and each one's spaced out about 20 frames. So I have just to change that to gotoAndPlay(30). And let's go ahead and test out this button. It's really simple. I still need to apply this, but again, it stops at this point in time. And if I click on this button, it goes to Frame 30, plays it, and then it reaches that second stop action right there and stops. So that's perfect.

You know the next step is to make these other buttons to work, but it follows the same process. Again, I'm going to make sure I'm in Frame 1. I'm going to select the Portfolio button. And keep in mind that I'm not selecting the text. There's text on top. I'm actually selecting the button back there. So I will select Click to Go to Frame and Play. Apply that. And it applies that same code. And still it tells me to modify that frame number. And each one's spaced out about 20 frames.

So this is on Frame 50 is where-- well, actually, let's just double-check that. Yup! There is Frame 50, perfect. So it goes there and it adds this comment. These comments, if I could be honest, are getting kind of annoying because it's just taking up a lot of room. Well, you know what? They're not needed. So I can even delete that right there. Now I can read this better. And if I take a closer look at this code, you can start to see the difference and what's going on here, because it's going to give me my instance name and it adds an event listener to this button that listens for the CLICK.

And on CLICK, it's going to fire off this function right here. So it's great that I list out to this code here. I can modify it further if I wanted to, but in general that's the structure for a common button. All right, let's move on along. Contact button, select it, double-click, Click to Go to Frame and Play. It's about a frame what? 70, right there. That's for the Contact button again. And let's close this, because lastly, I'm just going to select this Home button and do the same thing, which is apply that code.

All right, and I'll delete that comment. Now, this I want to go to about Frame 10 and play. Now you can also move this code around. Since they are going in order from left -to-right, I can always take this Home button code and drag it up near the top like that. So now it's sort of more in order as they're laid out on this page of the nave bar, so Home, About, Portfolio and Contact. It's looking good.

I will do a Test Movie. Stops where it needs to stop, About section, Portfolio section, Contact section and then Home. So everything works exactly as expected. It's perfect. Code snippets not only provide you the code; it gives you direction on modifying and within minutes, you can have a fully functional web site.

Find answers to the most frequently asked questions about Creating a First Web Site with Flash Professional CS5 .

Expand all | Collapse all
please wait ...
Q: I followed all the steps and suggestions in the "Adding a progress bar" video, but when I add the progress bar to my web site, I can’t remove it once the index.swf file loads up. The progress bar remains on the homepage and the rest of the pages. How do I make it disappear once the site loads?
A: To make it disappear, just make sure the progress bar is only in frame 1. If it’s on its own layer, then right-click on the 2nd frame in that same layer and select "Insert Blank Keyframe." That will make it disappear.
Q: Despite following the steps in the "Adding a progress bar" video, I cannot figure out how to keep the progress bar from appearing on a movie that has finished loading. How can I make the progress bar disappear?
A: Just add the red line below to the preloader.fla file. This will make the progress bar invisible: 
"function contentLoaded(evt:Event):void { //Optionally change to a clip holder and set progressbar visibility. addChild(contentLoader); progressbar.visible = false; }"





Don't show this message again
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Creating a First Web Site with Flash Professional CS5.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a Member and Create Custom Playlists

Join today and get unlimited access to the entire library of online learning video courses—and create as many playlists as you like.

Get started

Already a member?

Log in

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

You started this assessment previously and didn’t complete it.

You can pick up where you left off, or start over.

Resume Start over

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.