Cause for "A script in this movie is causing Flash Player to
run slowly" alert
While viewing a Adobe Flash movie in any Adobe Flash Player
environment (browser, standalone, or projector), an alert appears
stating "A script in this movie is causing Flash Player to run
slowly". Additionally, the message box gives the viewer the option
to abort the script, as can be seen in
Example
Reason
Adobe Flash Player will present this alert when a single
script (for example, a one-frame ActionScript loop) continues to
run for 15 seconds or longer. Giving viewers the option to end the
script helps the Flash Player prevent an SWF file from freezing the
viewer's browser or system indefinitely.
Note: The warning dialog box has Yes and No buttons. After
pressing the No button three times (approximately 15 seconds in
between prompts) the data is correctly loaded and displayed.
Solution
The solution to this alert can vary, just as the specific
cause will vary.
It helps to first understand that the alert itself is not
really the problem. The real problem is the performance of the
application. The alert prevents the user from closing the
application because they believe it is crashing.
The timeout of this alert cannot be altered, however, 15
seconds is about as long as one might want to wait for an
application to become responsive.
The most common cause of a long delay is loading large
amounts of data, or manipulating large amounts of data
(specifically, string manipulation, or similar work that is
typically time-intensive in client-side applications). It could
also be a combination of both.
Loading large amounts of data
If the application loading large amounts of data (for
example, 1000 records returned from a query,) consider the delivery
mechanism. Most applications cannot usefully display a set of 1000
records in one view. Instead, load and display data in small
chunks. This may solve a variety of problems in the application:
overall performance, usability, and as a side benefit it avoids
triggering the timeout alert.
Note: The number 1000 in this example is an arbitrary number.
The maximum number of records allowed before this alert box appears
depends on the amount of data in the XML file, the connection
speed, and the speed of the client machine.
Examples:
• Adobe DataGrid Component
It's difficult to work with many records at once in the
DataGrid.Pull in small chunks of data, about as much as can be
efficiently displayed and used at once, and you should have
improved results. 100 records at once could suit the DataGrid
better than 1000, for example.
• Loading Large XML Files
Loading excessively large XML files can cause the script
timeout error.
Time-consuming processing
The code may require more client-side processing than can be
done in Adobe Flash Player in 15 seconds on your target machine.
• First, troubleshoot and locate the specific code that
causes the delay. Breakpoints and trace are very useful features in
isolating problem code.
• Once you locate the slow code block, consider the
task it is performing. Some tasks, such as heavy string
manipulation, can be time consuming. If heavy string manipulation
is required, consider breaking it up into smaller tasks, or
performing the task server-side.
• One way to break up a code block into smaller pieces
of code is to spread the function or loop across multiple frames to
'distribute' the processing. The code may not run as quickly as a
pure block of code on a fast machine, but if heavy manipulation is
required, you can make your application more accessible to slow
machines by considering different methods.
For example, to spread a loop out over several frames:
You might evaluate a variable in an if statement. If the
variable returns 'true', have the movie break the loop by going to
the next frame. If the variable does not return 'true', then have
the movie loop back to the first frame (usually two to three frames
back) of the movie. When you want to break the loop, set the
variable to true.
Before deploying an application, test early and often in an
environment matching the lower end of your target audience. You may
discover performance problems, or produce the timeout alert, when
machines with faster processors or connections may not have a
problem.
Additional Information
For additional information refer to Inconsistent results
loading large amounts of data:
TechNote
16309