Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Loading multiple external images

From: Creating a First Web Site with Flash Professional CS5

Video: Loading multiple external images

What I want to do now is I want each one of my thumbnail buttons to load in the correct image when you click on it. It will load in that image right inside of this UILoader. Okay, so the first thing I need to do is give each invisible button a unique instance name. So I am going to select this first button here and in my Properties panel I am going to give it an instance name of port1_btn just like that and all of them are going to follow the same pattern. So I am going to copy that instance name and just paste it for the next button and just change this number to port2.

Loading multiple external images

What I want to do now is I want each one of my thumbnail buttons to load in the correct image when you click on it. It will load in that image right inside of this UILoader. Okay, so the first thing I need to do is give each invisible button a unique instance name. So I am going to select this first button here and in my Properties panel I am going to give it an instance name of port1_btn just like that and all of them are going to follow the same pattern. So I am going to copy that instance name and just paste it for the next button and just change this number to port2.

Again, this will prevent me from mistyping if I just paste in the instance name and change that one number. Last one, port6_btn. Now they all have instance names. All right, so far, so good. I am going to go ahead and select this first button and I am going to go to Window and I am going to open up the Code Snippets panel. Because for each one of these buttons what I am going to do is I am going to add an event handler.

That's this folder right in here. Notice I am going to select Mouse Click Event. So I am going to add a generic mouse click event to that button and all I need to do is double-click. Now it tells me that I can go ahead and add my custom code in a new line after start your custom code below is stated. So here it is, notice there is this trace statement, which just tells me that this button gets clicked on, and that's what I am going to start with is just sort of modifying the trace statement.

So port1_btn is what gets clicked on, so I am just going to copy that word and paste it right in here. So what this does is this is just going to give me a trace statement that's going to appear in my Output panel, saying that I clicked on this button. So I am going to do that for all of the buttons. I am going to select the second button, add a mouse click event for port2_btn. I am going to make sure that we have a trace statement for it. For port3_btn again I have just added another mouse click event. For port3_btn I can copy that instance name and paste it right in here for this trace statement so I know when it gets clicked on.

I am just double-clicking in this gray bar to hide the actions. Do it again for the fourth one. I can add that as welll, that mouse click event just like that. So I am starting to set-up the code for this little gallery. Add another mouse click event, port5_ btn just like that, hide that panel and then the last one double-click mouse click event, port6_btn, just like that.

Okay so I have just added six mouse click events, and they are all associated with these thumbnails, and I can scroll up and start to see all of it and notice how it adds all of these comments as well, which I really don't need most of these comments. I don't need six copies of the instructions so I can just start to delete those comments just like that. It's going to make my code easier to read seeing there is less within my Actions panel.

So here is all of my buttons. So far so good. I will just do a Control > Test Movie to test this out. I have my skeleton function set-up if you will. Go to my Portfolio section, and now when I click in my Output panel, you should see those trace statements appear, one through six. Perfect. Everything set up. So my next step is to target this movie clip which happens to be my portfolio background movie clip, because inside of it I also need to target this UILoader and for this UILoader, I need to change that content.

So let's take a look at that. Let's close my Actions panel, go back to my Timeline and if I select again, this is my Portfolio background, just like my Properties panel says. It's my Portfolio background. So I need to give this a specific instance name, and I will just call it portfolioBkgd, and I will just copy that. Okay, so I have targeted this movie clip. Now I am going to double-click it to go inside of it, and then I am going to locate this UILoader.

Remember, I have these other layers locked to allow me to select the UILoader. It also tells me in the Properties panel that I have the UILoader selected. Now what I can do is give it a specific instance name. I am going to call it mainLoader just like that. So far so good, but for this mainLoader, what I want to do is I want to change the source to the appropriate image. So I am going to change the source parameter and redefine it. So I am going to go back to scene 1.

I am going to go where that code was added, because all that code was added was right here in Frame 61. So I am going to go to Window > Actions and here is all of my code. Okay, now I can go ahead start adding on a new line the code I need to add. So I am targeting the portfolioBkgd, and then I am going to type a period because inside of that portfolioBkgd is the mainLoader and what I want to change with that mainLoader is the source.

I want to change its source and make it equal to something else entirely. What is that something else? Well, it's going to be another image, but I need to make sure that image exists. So I am going to go into the ExerciseFiles folder, assets, and I am going to locate this images folder, and these are the six images that I want to locate. I am going to go ahead and copy them and I need to put them in the images folder, Chapter 06/03 Begin.

I am going to put them in this images folder here, and I will paste them in. But what's important to note is that my Flash file is right here, and I need to make sure my images exist within a folder in the same location within that images folder. So I am targeting port1, port2, port3, so on and so forth. So lets go back into Flash. For port1_btn I am going to target the images folder, port1.jpg, just like that.

It looks pretty good. So in fact, I am just going to copy this line because I want to do the same thing for the port2 _btn, but I want to target that second image just like that. Same thing for this third image. This button is actually going to load in that third image right there. Again, it's just a copy and paste. Just be aware of what button you are referring to.

So port4_btn. Just beneath the trace statement for each one I can target that new image. Lastly, port6_btn that button is going to open up that jpg. All right, everything looks good so far, but the true test is of course testing the movie, and I will click one the Portfolio section. I am still going to get my trace statement pop-up but if I click on this second image you can see it load that it still gives me this trace statement, third image, fourth image, fifth image, sixth image.

So now my gallery is completed. Each time I click on a button, it dynamically loads in the correct image. All those images are external from the main Flash file, so it keeps my main Flash file small while still giving the user the ability to load in additional images.

Show transcript

This video is part of

Image for Creating a First Web Site with Flash Professional CS5
Creating a First Web Site with Flash Professional CS5

34 video lessons · 28225 viewers

Paul Trani
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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

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 Professional CS5.

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


OK
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
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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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
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.