Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
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.
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.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.