Join Paul Trani for an in-depth discussion in this video Setting up a portfolio, part of Creating a Portfolio Web Site Using Flash CS4 Professional.
- View Offline
The first thing you want to do when creating a portfolio is to figure out the design and how it will function. Then you can focus on the best way to execute it. So I'm going to go to the Portfolio section. And as you can see, there is a large image in the center and then supporting text just beneath it. There is also the thumbnails, the small images below that as well, and when you select a thumbnail, it will load in the upper area and so will that text. So that's what I want to do, but I want to be smart about how I develop this, because I want all of these images to be outside of the SWF file, because if they are embedded, then this file is going to be really large.
So what I want to do is make sure,all of these images are outside of the SWF and then they get loaded in. So what I'm going to do is I'm going to have a UILoader component that's going to load in the large image and then write some code to load in the small images. All right. So the first thing I need to do is identify the images I want to use. So I'm going into these Exercise Files/Assets, into the design folder, into portfolio and I'm going to take a look at the large folder and the thumbs folder.
And these are the images I want to use. I have large JPEGs in here, and then thumbs that match up perfectly in the thumbs folder. So all I need to do is copy those folders and put them in the current folder I'm working in. 05/01 begin and I'm going to create a new folder called portfolio. And I'm going to paste both of those folders in there. All right.
I'm going to start with the UILoader component. That's going to load in this basketball.jpg. So I'm going to go to my portfolio.fla file and here is my large image that I want to replace, so I'm just going to delete that image and what I want to do is replace it with a component. So Window>Components and I want to select the UILoader component and just drag it right on to the stage. Now I can go ahead and resize it.
So I'm going to just zoom out by holding down the Command+Minus to zoom out and now I can start to scale this out. So what I've done there is I've hit the Q key. If you hit Q, that will select your Free Transform tool, allowing you to scale and adjust the size of this item. Another way to do it is just to use, of course, your Properties panel. So the height I want to be about 400 pixels and then the width can be wider.
But I definitely don't want my UILoader component to be too large, as far as the height, because it does say portfolio here at the top. So I'll just kind of position it right there and then make sure this text, if I select my Selection tool, and this text is underneath that UILoader component. And I'll just use my arrow keys to fine tune it. So, it looks good so far. Here is my UILoader component, and what I want to do is I want to load in that basketball.jpg.
So I'm going to go to Window down to Component Inspector and in the source panel, I'm going to type in portfolio, because inside of that portfolio is a large folder and inside of there is the basketball.jpg, just like that. I have mapped it directly to that source. And I do want to scale the content and that's why I like the UILoader component, because regardless of the size of your portfolio piece, it will always scale it down so it fits within this area.
I made it extra wide in case, I have sort of more of a panoramic image, but that should do the trick. In fact, I'll just do a Test Movie, and yup, just like I expected, the image loads in and everything is looking great. Okay, so the next thing I want to tackle are these thumbnails. So I'm going to create an all thumb thumbnails movie clip and inside of that movie clip, I want to start loading in the different little thumbnails. I'm only going to do two right now, but in general, that's what I want to pull off.
I'm going to close that SWF file, close that Component Inspector and Command+Plus will allow you to zoom in. So I really want to focus in on this. And this is going to be my all thumbs movie clip. So I'm just going to click and drag that into the Library, and I'm going to call this allThumbnails, because it's going to contain all of the thumbnails. And I'm just going to make it a Movie Clip for the Type and select OK.
And I'll even give it an instance name, allThumbnails, which I will use in a second. Now what I'm going to do is I'm going to double-click on this, and this large graphic, you know what? I don't need it. In fact, I'm going to load in all these images. So I'm just going to delete that altogether. Now let's go back to Scene 1, and now what this serves as is a positioning item for all of my thumbnails. So wherever I move this is where all my thumbnails will appear.
Okay, now I can go ahead and write some code that will pull in a thumbnail. So I'm going to take a look at my Timeline panel. I do see this layer 1, which I just don't need. I'll hit the Trash can to throw it away and create a new layer at the top and I'll just call it AS, for ActionScript. I'm going to select that first frame and I'm going to go Window down to Actions. All right. I am going to pin my code. I want you to get in the habit of pinning your code, so it doesn't move, regardless of what you have selected.
And now, I can go ahead and type in what I need to type in, because I want to go ahead and create a new Loader from the Loader Class. So, in fact, I'll type in a comment, LOAD THE THUMBNAILS. All right. That's just a comment for me, so I know what I'm going to do. var, I am going to create a variable or a box, if you will, called thumbLoader. It's of the type, Loader.
It's using the Loader class. So it's basically creating an instance of this Loader class. So there is functionality in here that I can use now. I'll show you what I mean in a second, because with the thumbLoader, I want to go ahead and load in the request. So new URLRequest. That turns blue. That's a good sign, because I'm typing that correctly, portfolio and inside of that portfolio folder is the thumbs folder and then, in there is the basketball.jpg, the small version.
End that quote. Close that with a parenthesis and I need to close it with another parenthesis and then end with a semicolon. So anytime I have an open parenthesis, I need to close it down as well. So always make sure these match up. That's a common error is sometimes you won't have, say, both of them at the end. So that's what it's going to load in and what I'm going to type next is thumbLoader.contentLoaderInfo. I'm going to add an EventListener.
It's going to listen for an Event COMPLETE. So once that image has been fully loaded in, fire off this function called thumbLoaded. Just like that, I'll create the function, thumbLoaded Event, and just be mindful that this word needs to match up with this word, but that's the type of method that we're using.
And then void, open curly brace, closing curly brace and now I can go ahead and type in what I need to type in. So I'm going to go ahead and add the thumbnail to the allThumbnails instance. So remember how I named that earlier? If I just minimize this by clinking in that gray bar, right down here this little dot if I select it allThumbnails, that's what I'm referencing. So I'll open up my Actions panel because for the allThumbnails, I want to addChild.
So I'm adding a Child and all that means is I'm just going to go ahead and attach this thumbLoader content, whatever it is, in fact, I'll just copy that word and I'm going to paste it right in here. It's going to add whatever content this has to the allThumbnails, so right where that dot is. So let me go ahead and do a Test Movie. I can see,sure enough, there is the little thumbnail. It loads in the correct spot and everything is looking great.
And I'm just going to do a little clean up now. I have plenty of spaces in here, some line breaks, I'll just go ahead and condense this down, because this loads in one thumbnail. And in essence, what I've created is my own UILoader component. So it's definitely really cool and this is actually more flexible as well, because I can control different properties of it. But if you want to load in another one, what you can do is copy that code, paste it just below and you might call this one thumbLoader2.
So thumbLoader2, I'm going to change that name everywhere, thumbLoaded2. So I just went in and changed the name of that function as well. And for thumbLoader2, I want to load in another image, cafebuena. That's another image in this folder right here. So it's going to place it right on top of my basketball image. So I really don't want that. What I want to do instead is thumbLoader change it's x position = 100.
So move it over 100 pixels, so it's not on top of this one. That's all I need to do. I can check the syntax and it says all the code looks good, and let's do a Test Movie. And as you can see, I don't see it right now. So there is obviously a problem and since it didn't throw an error, I know it's an issue with one of my instance names. And what's happening is I've change this to thumbLoader in most places, except for right here.
So right here, thumbLoader2 is where you need to add it. And I point that out because if Flash doesn't throw an error, it's probably an issue with your instance names. So if I change that to thumbLoader2, I do a Test Movie, I can see cafebuena loads in, basketball loads in right there. So they are both loading in and it looks pretty good and even right here, these are kind of changing places, but I can go ahead and type in 2 there and I will run this one more time, just by hitting Command+Return, I can see that they are in their appropriate places.
So again, all this content is now external from the Flash file, making this initial file size really small and then you'll see the content start to load in. Now I can start to add many different thumbnails down here if I want to, but all that content is external. It makes my initial file size small and it just serves up content faster to the user.
- Optimizing and publishing a Flash web site
- Designing a professional photo or video portfolio
- Adding button interactivity
- Adding functionality to portfolio thumbnails
- Displaying content with XML
- Adding audio to portfolio presentations