Viewers: in countries Watching now:
Flash and ActionScript are ideal for creating flexible, easily updatable web sites that are both unique in design and small in file size. In Creating a Portfolio Web Site Using Flash CS4 Professional, Adobe Certified Instructor Paul Trani shows how to exploit Flash to create a web site that showcases work to clients and prospective employers. Find out how to add dynamic navigation, animation, and video to a page, and how to load, sort and display XML that enables portfolio content to be updated without opening Flash. This course is designed to take your existing tweening skills and gotoAndPlay code and walk away with a fully functional Flash site. Exercise files accompany the course.
One of the final things you're going to want to do with your site is make sure you're using preloaders where you need them. Well, what is a preloader? It's basically an indicator that tells the user what's going on. Usually, it's a percentage preloader that tells the user how much has been downloaded. So really you just want to review your content, determine the larger items, say, for instance, I am going to go into the portfolio section and just take a look at these images. Now I could actually put some pretty large images in here. Currently, these ones are fairly small, but as I add to my site, I could have some very large images.
So that's where I'm going to use the portfolio.fla to add my preloader to. So I'm going to double-click on the portfolio.fla and I'm going to go that first frame in the AS layer. Then I am going to go to Window and open up the Actions panel. Now I'm going to go ahead and pin my code. So it doesn't move in case I select something else. I'll move this up. Now just to kind of review, I do have this very large loadThumbnail function and in this loadThumbnail function, it creates the thumbnails and then also has this EventListener that listens for the Click.
So this is where I want to put my preloader when they click on the thumbnail. I then want to update a text field letting the user know that the image is being loaded. What I want to target is this largeUILoader. That's what I want to reference. So I'm just going to copy this name and add a comment, Add Preloader to images.
largeUILoader, well, just like most things in this code, it's actually an EventListener so I'm going to add an EventListener and this EventListener is going to be a ProgressEvent.PROGRESS is going to be the specific method that I'm going to go ahead and listen for. So I'm going to select PROGRESS and as pieces of this image gets downloaded, the Progress is going to update and the Progress is really going to fire off a function, so I'll just type in largeImagePreloader as that function name.
So as bits are downloaded, fire off this largeImagePreloader. So I'll copy that name, just beneath this EventListener, I'm going to go ahead and type in function largeImagePreloader. It's going to be an event: ProgressEvent, there it is. As soon as it highlights, you can hit Enter, but I need to make sure this and this matches up and then the typical structure of a function is what I'll add.
Between these two curly braces is where I want to put my preloader. So maybe the one I want to try initially is a trace. So in this trace statement, just for my own testing purposes, I'm going to see how often this Progress is firing off. In fact, I'll just type in loading. I'm going to go ahead and select auto format just to make sure everything is lined up and everything within this function is going to fire off at the Progress of this JPEG that's being downloaded.
So I went to Control>Test Movie, here are my images and in order to simulate download, what you need to do is go under View, and you should first check your Download Settings. Now I have mine set to 56K. I'm not really targeting 56K modems, but just to show you the progress, you probably want to test DSL. But as soon as you have the appropriate one checked, you can Simulate Download. So select that and let's give it a second.
It might take a little longer since it's a 56K modem and that makes you appreciate DSL. But this is a good test, because it's slowly going to try to load in all of these thumbnails and there are all my images. So if I select any one of these, I click on it in my Output panel, you should see it loading. In fact, I'll just scoot this over a touch. Click, you can see loading. It gets fired off, actually many, many, many times.
Now I am going to just go ahead and click in the Output panel. just to scroll through and show you that how many times it's being printed out, plenty of times. So let's go back to my code. I am going to go to Window>Actions and right in here, instead of my trace statement, I'm going to type in the code I need. So I want to create a variable called percent and it's going to be a Number. This number is going to be equal to the event.bytesLoaded, divided by the event.bytesTotal.
Event.bytesLoaded is this event is basically what's called. So it's going to be that largeImage is what event is referring to. So it's going to take the bytesLoaded and divide it by the bytesTotal. It actually returns a very small integer, so what I need to do is I need to multiply it. In fact, since I want this to be a percentage, I'm going to wrap this in parentheses and from there, what I can do is within those parentheses I can multiply it by 100, because these will only return zero to one.
This will give me more of a realistic percentage number, but it's not going to be a whole number either. If that's the case, what I need to do is type in Math.round. This will round this non-whole number up or down to the nearest whole number and put it within this percent variable. Now I can go ahead and use that percent and I could do another trace statement, but what I want to do is I want to put it inside of a text field.
So I'm going to go ahead and select the Text tool and in the Timeline panel, move that out of the way, I'll expand this out a little bit. Underneath mainimage, I'm going to create a New layer and this is just going to be called preloader and now let me go ahead and turn off that mainimage. But basically where it was is where I want to go ahead and a text field. So there's my text field. I'm going to kind of adjust it accordingly and with that text field selected, I want to look in my Properties panel and make sure it's set to Dynamic Text.
You also want to make sure that you have the Color that you want, the Size of the font that you want as well. Lastly, I need to give it an Instance name of percent_txt, because it is a text field and I will copy that name. Now I'm going to go back into my code and right within this function, I can paste percent_txt and I can type in text is equal to percent right here, That's what I want.
And I don't want to just show those numbers. I want to add, within the quotes, a percentage sign. All right. Now that is looking pretty good. In fact, I'll just end with a semicolon. It's going to go ahead and give me the percentage and put that Percentage sign right next to it and I can go ahead and test this out. Now so you'll notice that this actually is misspelled, so I need to say percent. All right. That should take care of it. I'm going to a Test Movie. There are my images.
Now it's not tracing out anything, because what I want to do is I actually want to see the text field in the center there. So I'm going to change my Download Settings to DSL and I am going to go to View>Simulate Download. So I'm going to select this and you're going to see the images load down here. With them loaded, I'm going to go ahead and select an image and you can see the percentage working, just like that.
So it's fairly straightforward because it is an EventListener and we're getting used to EventListeners. It's just a matter of getting the bytesLoaded divided by the bytesTotal and making sure the bytesLoaded is multiplied as well. But I can go ahead and use this, I can copy it, I can paste it into any of the other sections for any other item I want to add a preloader to and it will work just fine.
Find answers to the most frequently asked questions about Creating a Portfolio Web Site Using 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.