Solved

Strategies for Flash Movie speed optimization

Posted on 2003-12-01
11
511 Views
Last Modified: 2007-12-19
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.

Thanks!
Darren
0
Comment
Question by:g8z
  • 3
  • 2
  • 2
  • +1
11 Comments
 
LVL 7

Expert Comment

by:ssdesign
ID: 9856114
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 :)

0
 
LVL 9

Expert Comment

by:OBCT
ID: 9856158
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.

Cheers

-OBCT
0
 
LVL 7

Expert Comment

by:ssdesign
ID: 9856550
hi, you didnt say anything incorrect but just said whatever i said above in different words... ;)

please dont mind this comment.....
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9856648
Sorry ssdesign, I didn't see yours. I thought mine was going to be the 1st comment. :)
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:g8z
ID: 9859427
hi,

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

http://69.61.15.245/as.zip  (only Actionscript, no PHP)

To see the movie in action, go here: http://69.61.15.245/client/siriani/

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:

http://69.61.15.245/source.zip (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 () {
                  f();
            };
            f();
      }
}

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

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

// DataGrid add-ons from tufat.com
#include "./as/DataGrid.extensions.as"

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

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

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

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

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

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

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

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

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

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

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

// path to Siriani system root
var phpPathLoader = new LoadVars();
phpPathLoader.load("path.txt");

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
showLogin();
Selection.setFocus(loginScreenInstance.loginForm.userID);
stop();

// default variables, e.g. for popup loading
var popupX = bodyX+10;
var popupY = bodyY+10;
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 9859978
that is still way too much code for the first frame...

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

http://www.macromedia.com/support/flash/publishexport/stream_optimize/stream_optimize06.html
http://livedocs.macromedia.com/flash/mx2004/main/01_doc49.htm


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...


rp


0
 
LVL 22

Expert Comment

by:rascalpants
ID: 9860040
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...


rp
0
 

Author Comment

by:g8z
ID: 9861533
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 Ghostwire.com, 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)?

Thanks,
Darren
0
 
LVL 22

Accepted Solution

by:
rascalpants earned 500 total points
ID: 9866987
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...


rp







0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to record live broadcast.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now