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

Creating a preloader

From: Creating a Portfolio Web Site Using Flash CS4 Professional

Video: Creating a preloader

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.

Creating a preloader

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.

Show transcript

This video is part of

Image for Creating a Portfolio Web Site Using Flash CS4 Professional
 
Expand all | Collapse all
  1. 1m 41s
    1. Welcome
      1m 7s
    2. Using the exercise files
      34s
  2. 24m 1s
    1. Understanding web design
      2m 44s
    2. Creating a Flash file
      3m 18s
    3. Importing a design from Photoshop
      7m 45s
    4. Optimizing the design
      10m 14s
  3. 13m 59s
    1. Dynamically loading an image
      3m 37s
    2. Loading random images
      10m 22s
  4. 47m 38s
    1. Creating menu buttons
      8m 18s
    2. Adding functionality to buttons
      8m 56s
    3. Adding navigation
      9m 45s
    4. Creating transitions
      12m 0s
    5. Simplifying code
      8m 39s
  5. 26m 11s
    1. Creating web site sections
      7m 41s
    2. Dynamically loading sections
      11m 7s
    3. Linking to web sites and email addresses
      7m 23s
  6. 29m 18s
    1. Setting up a portfolio
      12m 31s
    2. Adding functionality to thumbnails
      10m 10s
    3. Allowing for unlimited thumbnails
      6m 37s
  7. 41m 17s
    1. Benefits of using XML
      4m 42s
    2. Loading XML content
      4m 34s
    3. Sorting XML content
      7m 32s
    4. Displaying XML content
      7m 35s
    5. Using XML to create thumbnails
      8m 41s
    6. Displaying content with thumbnails
      8m 13s
  8. 25m 59s
    1. Creating and importing video
      9m 47s
    2. Adding a Full Screen button
      4m 15s
    3. Creating custom video controls
      4m 50s
    4. Adding functionality to video thumbnails
      7m 7s
  9. 9m 12s
    1. Adding audio to buttons
      5m 30s
    2. Adding audio to dynamically created buttons
      3m 42s
  10. 21m 19s
    1. Applying professional transitions
      9m 26s
    2. Creating a preloader
      8m 56s
    3. Publishing a web site
      2m 57s
  11. 3m 15s
    1. Reviewing the "corporate" Flash site
      1m 40s
    2. Reviewing the "artistic" Flash site
      1m 35s
  12. 12s
    1. Goodbye
      12s

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 Portfolio Web Site Using Flash CS4 Professional.

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.