Articles Archive
Articles Search
Director Wiki
 

Flash + Director = Slow

July 12, 2000
by Gary Rosenzweig

This week I want to rant a bit about what bugs me the most about Director nowadays: Flash members. These versatile little guys have quickly been adapted by many Director shops as the primary member type. More and more illustrators are producing their artwork as Flash movies, rather than bitmaps. The result is a stylized vector look, which is fine, but it also means a huge speed hit for movies.

This is unfortunate. I really do like Flash members. They look cool, they scale and rotate nicely, and they can sometimes (but not all the time) be really small. However, the speed hit is enormous. Lets look at an example. The following Shockwave movie contains four Lingo-controlled animations. A black circle moves across a field of red. The black circle is either a bitmap or a Flash member. The red field is also either a bitmap or Flash member. The circle will move from horizontal position 0 to horizontal position 300. It will do this at a maximum of 999 fps. A timer will determine how long it takes to do this and throw up an alert dialog with this time in milliseconds.

A Director 8 sample movie is available for download in Mac or PC format.

The results of these tests will vary from machine to machine. They will also be different in Shockwave and Director. My results, from Director 8, on my G4, are:

Bitmap over Flash 1630 milliseconds
Flash over Flash 1750 milliseconds
Flash over Bitmap 480 milliseconds
Bitmap over Bitmap 320 milliseconds

As you can see, the use of Flash members really slows things down. It took more than five times as long to use all Flash as it did to use all bitmaps. Plus, the all-bitmap option was close to 999 fps (320 milliseconds to move 300 frames), which means that it might actually have been even faster had there not been the 999 fps limit. How can you speed this up? Well, one method often suggested is to turn off the loop member property of the Flash member. Another method would be to use the low quality setting for the Flash members. I have included ways to turn these on or off in the movie above. However, as you can see for yourself, they make little difference.

So, the only real way to speed things up is to stop using Flash members. I've had to do this for several fast-action games. I leave the Flash members on instructions pages and the like, but only use bitmaps in the actual game. One popular idea is to have Flash members embedded into the Director movie, but to use Lingo to convert them to bitmaps before displaying them on the screen. For instance, if you have a Flash member called "background", you can create a bitmap of it thus:

newMem = new(#bitmap)
newMem.image = member("background").image

Then, you will need to use Lingo to swap the member on the Stage so it now uses the bitmap member instead of the Flash member. Before you save the movie out as a Shockwave movie or Projector, just delete the bitmap images created by your testing and let the Lingo code create a new bitmap when the user runs the movie. Other than this trick, the only way to speed up Director movies with Flash members is to be smart about when to use them. Large backgrounds should be bitmaps. Small sprites that need to be rotated a lot could be Flash members.

The question I have, which may not be answered until Director 9 or 10, is: does it have to be this way? Is there something inherent about Flash that means that Flash members will always be slow? Or, is there something that the Director engineers can do to allow Flash members to be as fast as bitmaps?

Gary Rosenzweig's latest book is "Advanced Lingo for Games." In it, you can find the source code for more than 20 complete games. More information about the book can be found at http://clevermedia.com/resources/bookstore/book4.html. It can be purchased there, or in your local bookstore.

Gary Rosenzweig is the Chief Engineer, founder, and owner of CleverMedia, a game and multimedia development company in Denver, Colorado. He is the author of ten books on Macromedia Director and Flash, including his latest, Special Edition Using Director MX.

Copyright 1997-2017, Director Online. Article content copyright by respective authors.