Home arrow Flash arrow Page 6 - Building Preloaders
FLASH

Building Preloaders


A preloader prevents a Flash movie from playing back until the movie can stream properly. Without a preloader, you may find that your movie tries to play frames that haven't been loaded yet, leading to unacceptable playback behavior. This article explains how to build a preloader. It is excerpted from chapter 20 of the Flash 8 Cookbook, written by Joey Lott (O'Reilly, 2006; ISBN: 0596102402). Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 5 stars5 stars5 stars5 stars5 stars / 16
February 22, 2007
TABLE OF CONTENTS:
  1. · Building Preloaders
  2. · 20.1 Determining How a Movie Will Download
  3. · 20.2 Building a Simple Preloader
  4. · 20.3 Building a Preloader that Displays Load Percentage
  5. · 20.4 Using a Progress Bar to Create a Graphical Preloader
  6. · 20.5 Creating Preloaders for Files with Exported Symbols
  7. · 20.6 Creating Preloaders for Files with Components

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Building Preloaders - 20.5 Creating Preloaders for Files with Exported Symbols
(Page 6 of 7 )

Problem

Your have a file that exports movie clips for ActionScript, and you want to add a preloader.

Solution

Use the same preloader principles discussed earlier in this chapter. In addition, uncheck the “Export in first frame” option for each exported movie clip within the library.

Discussion

As you learned in Recipe 11.17, you can tell Flash to export a movie clip symbol even if it is not used at authoring time. That enables you to programmatically add instances of the movie clip using ActionScript. With a few simple movie clips exported for ActionScript, you won’t likely notice any effect on the preloader. However, with many complex (particularly bitmap) movie clips that are exported for ActionScript, you may start to notice that the preloader doesn’t appear immediately. It’s possible that the preloader may not even appear until most of the file has downloaded. This is due to the default setting for movie clips exported for ActionScript—they are set to export on the first frame. Thus every exported movie clip must download before Flash will play back even the first frame.

There is a relatively simple solution, however. Although the default setting is such that Flash-exported movie clips are exported on the first frame, you can tell Flash to use an alternate frame instead, with the following steps:

  1. Uncheck the “Export in first frame” option for each movie clip symbol. You can access the option from the Linkage properties dialog box. By default, the “Export in first frame” option is checked when you check the “Export for ActionScript” option. However, when the “Export for ActionScript” option is selected, you can independently toggle the state of the “Export in first frame” option.
  2. Place instances of the movie clips on the stage at authoring time. That way Flash knows what frame to use in order to export the symbol.

The second step may seem counterintuitive. However, it is simply the way in which you communicate to Flash where to export the symbol. The dilemma that arises is then that you frequently don’t want those symbols to appear in the exported movie on any frame unless they were placed there with code. So placing an instance on the stage at authoring time seemingly defeats the purpose, or at least causes an obstacle. The solution is to approach the Flash project in a somewhat nonlinear fashion. Even though a timeline plays from first frame to last frame by default, there’s no reason it has to do that. As you’ve already learned, you can use simple ActionScript commands to tell Flash to stop, play, and jump to any frame within a timeline. Therefore, you can always place the movie clip instances on a frame that is never played. For example, you can place the preloader on frame 1, the movie clip symbol instances on frame 2, and then the actual content starting on frame 3. Within the script on frame 1, you can instruct Flash to jump to frame 3 once the file has downloaded.


blog comments powered by Disqus
FLASH ARTICLES

- More Top Flash Game Tutorials
- Top Flash Game Tutorials
- Best Flash Photo Gallery Tutorials
- The Top Flash Tutorials for Menus
- 7 Great Flash Tutorials
- Adobe Creative Suite 5.5 Now Available
- Critical Flash Vulnerability Heats Up the Web
- More on Nonpersistent Client-Side Remote Sha...
- Nonpersistent Client-Side Remote Shared Obje...
- Using the Decorator Pattern for a Real Web S...
- Using Concrete Decorator Classes
- Delving More Deeply into the Decorator Patte...
- The Decorator Pattern in Action
- A Simple Decorator Pattern Example
- Decorator Pattern

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials