Strategies for Flash Movie speed optimization

Hello Experts!

I have a very large Flash movie with over 10,000 lines of code, with many externally loaded .swf files, lots of UI components and database interactivity, but no animation. There are no infinite loops in the system, and everything basically works, but it's very slow. I'm talking about basic mouse clicking and moving draggable windows around the screen and such... in fact, it gets slower the more I use it, but even when it initially opens it's very, very slow.

I'd like some suggestions on things that I can do to improve the overall movie speed... for example, are there certain mouse handlers that can be disabled, and if so how? Are there certain common optimizations that can be made to Macromedia's UI components? Are there certain functions in Flash that are known to be very slow, which I should avoid using? And so on..

I award points for this question based on how effective your suggestion is to improving the performance of my system.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I have a doubt. Is all the code of 10,000 lines on one frame?

What is the level of processing this code does? like for any single event, do you have to run long codes? If this is the case then you might have to split you code or rearchitecture your scripting to make it robust.

Also you can check if you are using too many loopings in your code. This could also be one of the cause.

In the end, few basic question:
1. What is the configuration of your system?
2. What is the version of actionscript and Flash software you are using?
3. What if the version of Flash Player installed on your system?

Would really like to help you with this one, its challenging :)

I know this won't help much but I'll let you know anyway.

-The only functions that tend to slow flash down are loops and functions that animate objects, such as "MC1._x += 1"
-UI components tend to require alot more coding, so if you can find away to reduce on the number of your components, your program will run a bit faster. However I do realize that sometimes you can't avoid using UI c's.

>There are no infinite loops in the system

As I've said before, loops tend to slow down flash and in the extreme cases, it can crash flash. Obviously you won't be able to rewrite the system that's been created but you can make an attempt at reducing the number of loops in the code.

>with over 10,000 lines of code

Try reducing the of lines of code in each functions. The more lines of code flash has to read per function, the slower everything will run.

Just a note for the other experts:
If I have said anything that isn't correct, please let me know so next time I'm not making assumptions.


hi, you didnt say anything incorrect but just said whatever i said above in different words... ;)

please dont mind this comment.....
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Sorry ssdesign, I didn't see yours. I thought mine was going to be the 1st comment. :)
g8zAuthor Commented:

All of my code are in external .as files, which you can take a look at by downloading them all from here:  (only Actionscript, no PHP)

To see the movie in action, go here:

Login using "d" as the username and "g" as the password, without the quotes (but please don't make any changes to the system content). If you click around the various tabs and sub-tabs and icons and such, you'll notice the movie gradually slows down. Even upon initial opening, the system is incredibly slow. Also if you navigate among different records in the various databases, the movie slows down. This system is an XML-based database navigation system.

The main .fla can be downloaded from here: (1.5 MB)

In frame 1 of my movie I have this code. So yes, it's all in one frame, but I since I stop() after frame 1, I didn't think that this would be a problem. There is no animation in this movie at all.

/** Useful debugging tool */
function assert(boole, msg) {
      if (!boole) {
            trace("ASSERT FAILURE: "+msg+"\n\n");
            f = function () {

// popup level for ComboBox lists
_global._popUpLevel = 1000000000;

//string manipulation functions
#include "./as/"

// DataGrid add-ons from
#include "./as/"

// extra Array class functions
#include "./as/"

// drawing functions (e.g. Rectangles, Lines, etc)
#include "./as/"

// regular expression class
#include "./as/"

// text mask class
#include "./as/"

// adds setEnabled method to FScrollPane Component
// and setEnabled2 methods to other UI Components
#include "./as/"

// extra functions that are needed to process the result of popup forms
#include "./as/"

// LocalConnection functions
#include "./as/"

// method to change the current screen based on the current
// tab/subtab/icon state
#include "./as/"

// Position icons and set click/change handlers of screen elements
#include "./as/"

// Various functions that don't fall into any other category
// E.g. Login/logout, etc.
#include "./as/"

// functions that are called every X seconds (i.e., "periodically")
#include "./as/"

// path to Siriani system root
var phpPathLoader = new LoadVars();

phpPathLoader.onLoad = function(success) {
      if (success) {
            _root.path = this['path'];

            // check for a valid path variable; if none, then display error
            if ( _root.path == null )
                  assert( false, "_root.path is non-existent" );
      } else {
            // display error in Help window
            trace("path.txt could not be found");

// show the user login screen & set focus to the login textfield

// default variables, e.g. for popup loading
var popupX = bodyX+10;
var popupY = bodyY+10;
that is still way too much code for the first frame...

take a look at these two links, and see if they help:

also, even if you don't have a lot of animation, you need to think about your SWF like this...

here is an analogy that I read in a book...

Think of the CPU and the SWF together as the Teacher of a grade school class...  A normal class room(SWF) and teacher would typically be able to handle about 20 students with ease.  Now image is you keep adding students, or even start out with a ton of students, lets say about 100.

A teacher would have a very hard time trying to keep track of all of those rowdy students, and it would take the teacher a longer time to tell each student what to do...

in the same theory, you need to think of movieclips and other objects in Flash in the same way.  If you have tons of UI components that need to be tracked by the SWF/CPU, then you computer will always run much slower...

try to optimize your project by using more steps in the process...  maybe instead of displaying a bunch of UI components on the screen all at once, you should make the user go through steps...  this way you can load and unload Flash Objects all at ones...  the same thing can be done for external AS files...  if you don't need to use something until a later date, then don't even tell the SWF that it exists...

try this first, and then come back and comment...


yep, I just looked at your project, and it is information overkill...

Your application looks similar to an Enterprise Software Application like JD Edwards or PeopleSoft...  

Those types of programs run on applicaiton servers that have tons of power and resources that they can pull from...

you are trying to do the same thing on the web utilizing the users PC...  that just doe not make much sence...

Your User Interface needs some work as well, because you need to walk the user through the process....   This does not even look like a good example of an appication that should be using Flash...  This can be done much quicker using HTML forms and server side code...

You maybe should try a hybrid of HTML and Flash, and then you can utilize the resources of both...

g8zAuthor Commented:
hi guys,

Thanks for the comments. I agree that this system would be simpler and faster in HTML, but unfortunately it is extremely important to the client that page refreshes are eliminated. Also, they want to eventually incorporate various types of Flash animation into the interface. I'm afraid that not using Flash isn't possible at this point... we're basically just too far into the project.

Anyway, I'll try splitting up the #include files into different frames or loading them at different times. I'm also looking into using a different component set, like those provided by, or perhaps the Flash 2004 component set. My hunch is that MM's default components are a big part of the slowdown.

If I reduced the frame rate of the movie, do you think that would help things, since the CPU would have less computation to perform each second? Are there any other "easy" hacks that can be made? Also, if I simply put each #include reference on a different frame, will that help (even if the total amount of #included code is the same)?

You need to follow the approach of "If I don't need it yet, then I don't want it!"

The User Experience is the main problem here...  not the slow loading system...  

It seems that you have all sorts of navigation that will open up frames or scenes with a bunch of components and what not.

It would be wise to create a loading animation and a movieclip that is specifically designed to load and unload movieclips and code from the SWF.  This will tell the user that "The information needs to load", and they will patiently sit and wait(for a few seconds) because they know what their computer is doing...  it is loading the required components or database information...

While this loading animation is happening, this is when you would unload a movieclip and load the required movieclip...

The processor will not have to keep track of dozens of components and related actionscript, and will work much faster...

so I would first create a movieclip with a very simple "Loading Components"  or "Loading Data"  animation....

let the user know what is happening and they will forgive you for a slightly slower experience...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.