Start learning with our library of video tutorials taught by experts. Get started

Creating a First Web Site with Flash CS4 Professional

Adding multiple images to the portfolio section


From:

Creating a First Web Site with Flash CS4 Professional

with Paul Trani

Video: Adding multiple images to the portfolio section

Up to this point we've been able to modify movie clips using ActionScript, such as navigating through the different sections. But we can also modify the parameters of components as well. So here is a UILoader component and if I click on this button here, it's going to load in another image. If I click on this Back button, it's going to load in the previous image as well. So it's really just loading in Portfolio image 1 and then image 2, but it's dealing with this same component. That's what I want to do now is modify that component based on what you click on. So I'm going to close that final file and I'm going to go into my current project and I'm going to scroll down to the Portfolio section.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Creating a First Web Site with Flash CS4 Professional
3h 8m Beginner Apr 15, 2009

Viewers: in countries Watching now:

Information on how to learn Flash is prevalent, but it can be frustrating to understand how to make an entire working web site using this unique technology. Here's a course that cuts through the clutter and offers practical tools for creating a dynamic web site, even for first-time developers. In Creating a First Web Site with Flash CS4 Professional, veteran Flash instructor Paul Trani simplifies the process of integrating animation, video, audio, and user interactivity to create a site that is dynamic and appealing. The goal of this hands-on workshop is to teach web site-building skills for today's demanding interactive industry. Exercise files accompany the course.

Topics include:
  • Manipulating images for the best results
  • Integrating assets from other Adobe products
  • Creating buttons with ActionScript
  • Embedding links to external web sites
  • Exploring text layouts
  • Customizing interactive contact forms
Subjects:
Web Web Design Projects
Software:
Flash Professional
Author:
Paul Trani

Adding multiple images to the portfolio section

Up to this point we've been able to modify movie clips using ActionScript, such as navigating through the different sections. But we can also modify the parameters of components as well. So here is a UILoader component and if I click on this button here, it's going to load in another image. If I click on this Back button, it's going to load in the previous image as well. So it's really just loading in Portfolio image 1 and then image 2, but it's dealing with this same component. That's what I want to do now is modify that component based on what you click on. So I'm going to close that final file and I'm going to go into my current project and I'm going to scroll down to the Portfolio section.

If I double-click on this content movie clip and double-click again to enter this Portfolio movie clip, this is where my buttons exist. As we can see, I have this next_btn and this back_btn as they're known by their instance names. Now if I click on my Timeline, in my Timeline this is where I want to add my ActionScript to change this component. But notice how this component currently does not have a name, and I want to make sure I give it a name. I'm going to call it largeImageLoader. That's what we'll call it and I'll even select this name and right-click to copy it, so I want to keep that name in mind.

Now, I'm going to create a new layer and I'm going to call this ActionScript, right on this first frame in this layer is where I'm going to write my ActionScript that's going to be applied to these buttons. So selected that first frame, go to Window, to Actions. So if you recall the button called next_ btn and I want to add an event listener for it and the type is going to be a mouse event and I'm going to listen for the CLICK. Notice how I get this code hint. Well, I can use my Arrow keys to move down to the CLICK mouse event to select it.

Add a comma, and then I need to reference the function that's going to fire off when you click on this button, and this function is going to be called nextImage. End with a semicolon. So down three lines total, I'm going to add the function, nextImage and it's expecting this Event object, this mouse event. So I want to make sure this name matches up with this name. So it's expecting a mouse event. I don't want to return anything, so traditionally you'll just add the word void at the end with a colon. And then within these two curly braces, this is where my function calls are going to be. Anytime you call this function, whatever is within these two curly braces is going to be what is executed.

So what I want to start with is just a trace, so I'm going to trace out next image. So I have encompassed that with quotes in parenthesis and that's what will be traced out, nextImage, so I know that function is being called. Now, this second line that I'm going to type in, if I move my Actions panel, is I want to go ahead and change the parameter of the UILoader component. So I'm going to move my Actions panel down and I'm going to locate my UILoader.

Now I'm going to go to Window. All the way down near the bottom is the Component Inspector panel. So if I open that up you can see the different parameters that are available for this UILoader. As you can see there is many different parameters, but I'm most interested in this source parameter. Its name is source and it is equal to images/portfolio01. Well, for my Next button, I want to make the source parameter equal to the value images/portfolio02.jpg. So let's do that. I'm going to keep this name in mind. Source, select that first frame. Go to my Actions panel and I'll just type in the name of the UILoader component. Remember, I copied it earlier. So I'm going to right-click and I'm going to paste.

So that's the name of the UILoader component. I'm going to add a period and then I'm going to type in that parameter name, which was source. So the source is going to be equal to images/ portfolio02.jpg. So we just changed that source parameter with ActionScript. So let's try that out now. If I move that panel down, I'm going to go to Control > Text Movie. I'm going to click on the Portfolio section; I'm going to move this down, because we should see a trace statement as well. When I click on this button, we get portfolio02. jpg and we also get that trace statement that says nextImage. Because remember that's the name of the function that was called. And it works great, but our Back button does not work yet.

So I'm going to go ahead and add that functionality right now. And luckily, if I close that test file, the code is going to be the same with some modifications. So I'm going to select all of this code and I'm going to copy it and then I'm going to right-click and paste this code just beneath it. Now I'm going to modify this code for the Back button. So back_btn. I'm going to add an event listener. It's a CLICK event listener and it's going to fire off this function called backImage. So backImage is going to be this function here, so I need to change this name, backImage, and then I need to modify these two statements as well. backImage is where it gets traced out and then I want to change the source back to portfolio01.

All right, with that set up and it's looking good and often when I'm doing a lot of typing or coding, I might want to check the syntax, so I can hit that little Check button. And it does say this script doesn't contain any errors. So it should work just fine, I'm going to go to Control > Test Movie, and go to Portfolio. Now if I click on this Next button, it loads in image number 2, Back button loads in image number 1. So it works out great, and as you are able to see, I was easily able to use a similar button function like I would if I'm jumping to a new section. In this case what I'm doing is I'm modifying a parameter for the component which works quite well, I can use that same component for as many images as I want to.

This is very useful. I was able to change a parameter of a component to load in a different image.

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


Expand all | Collapse all
Please wait...
Q: If I create a website using Flash CS4 on a Mac, can I edit it on a PC using Flash CS4?
A: As long the file is saved as a .FLA file with the extention ".fla" typed at the end of the filename when saving on a Mac, it should open with no problem on a PC.
Share a link to this course
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.
Upgrade now


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.

Upgrade now

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

Congratulations

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

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


OK

Course retiring soon

Creating a First Web Site with Flash CS4 Professional will be retired from the lynda.com library on April 24, 2014. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion.


Become a member to add this course to a playlist

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

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

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:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



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.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com 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 lynda.com.

Sign up and receive emails about lynda.com and our online training library:

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

   
submit Lightbox submit clicked