Adobe Flex Authors: Matthew Lobas, PR.com Newswire, Shelly Palmer, Kevin Benedict

Related Topics: Adobe Flex

Adobe Flex: Article

Cover Story: How to Increase the Frame Rates of Your Flash Movies

How's Your Need For Speed?

When are surfaces regenerated? Changes to a movie clip that make the player regenerate the internal bitmap representation should be used sparingly; otherwise you defeat the purpose of the feature. The bitmap that is generated when you turn bitmap caching on for a movie clip will be regenerated every time you change any of the following MovieClip ActionScript properties:

  • _xscale
  • _yscale
  • _rotation
  • _alpha
  • _width
  • _height
  • filters
  • blendMode
  • opaqueBackground
  • transform
So, try to avoid changing any of these ActionScript properties on a regular basis.

The bitmap will also be regenerated when:

  • The timeline play head changes inside the movie clip
  • When the outer boundaries of the movie clip change
  • When you draw something inside the movie clip with the drawing api
  • When you attach an image or symbol from the library into the movie clip
  • Any of the above occur within a nested movie clip (child movie clip)
  • The movie's viewing window changes (i.e. The viewer Zooms in using the RightClick menu)
Memory Usage
Bitmap Caching naturally makes the Flash Player utilize more memory because for every cached movie clip the player has to store the vector data and the additional bitmap equivalent in memory. When you turn bitmap caching off for any particular movie clip, its bitmap representation is removed from memory.

You should be concerned about the amount of memory that your Flash Movie uses, because it can affect the performance of other applications that are running on the same computer as the Flash Player. The more memory the Flash Player uses, the less memory that is available for other programs to run effectively. Computers only have so much memory available to them; this comes in the form of RAM (Random Access Memory). Most computers nowadays have at least 256MB RAM. The operating system may provide more memory as and when required in the form of Virtual Memory. The Flash Player should never use that amount of memory, but now with the various new Bitmap related features added to the player, it is possible for Flash Movies to consume large amounts of memory in a short space of time so as the developer you should endeavor to minimize memory usage.

Before we talk about the specifics of bitmap caching memory usage, a little background information might be useful. Firstly, a bitmap is made up of pixels. It can be thought of as a grid of color values, which designate a particular color for each and every pixel. Each pixel is a cell in the grid. A bitmap that is 100 pixels wide, by 100 pixels high is described by a grid of 1000 color values, one for each pixel. Each color value in a bitmap is a binary number. A binary number is made up of bit's which can either be 0 or 1. This binary number will differ in length, depending upon the color depth of the bitmap. The color depth of a bitmap determines the range of possible color values that can be used in each pixel. For example, each pixel in a 24 bit image can be one of roughly 16.8 million colors. Those colors are formed by mixing together varying quantities of three primary colors, Red, Green and Blue. The three main colors are called Channels. Each channel can have 256 possible values (0255).

255 * 255 * 255 = 16.8 million
256 decimal is 11111111 in binary.

This binary number is 8 bits long. 8 bits is 1 byte. Therefore each channel in a color uses 1 byte. The bitmaps that are created by the Flash Player when it converts a movie clip into a surface have a 32 bit color depth. 32 bit images have four channels; Red, Green, Blue and an additional Alpha Channel. Therefore the color value for each pixel in a surface created by the Flash Player is 32 bits long, or 4 bytes.

4 * 8 = 32 bit

The bitmap that is created by the Flash Player to represent the visual state of a movie clip when you turn Bitmap Caching on will have the same dimensions (width and height) as the movie clip. A cached movie clip that is 100 pixels high and 100 pixels wide has 1000 pixels.

100 * 100 = 10,000 pixels

Each of those pixels will be 32 bits or 4 bytes. Therefore it will utilize a further 400,000 bytes of memory.

10,000 * 4 = 400,000 bytes

There are 1024 bytes in 1 kilobyte (KB). So, 400,000 bytes can also be said to be roughly 400 kilobytes.

Size Limits
Because of the possibility of this feature using excessive amounts of memory, Bitmap Caching will not work, if the dimensions of a cached movie clip are larger, or become larger, than 2880 pixels in either width or height. 2880 is a restriction Macromedia has put in place for all bitmaps in the player, to try and minimize excessive memory use. That is because a 2880 * 2880 movie clip that is cached will use up roughly 32MB of memory. Four of these cached movie clips with those same dimensions could potentially fill up a computer's memory and crash the machine.

It is worth noting here that if a filter effect is applied to a movie clip either in the Authoring Environment or using actionscript, then Bitmap Caching is automatically turned on and the cacheAsBitmap property will always return true, regardless of whether you turned Bitmap Caching off in the Authoring Environment or with ActionScript. To prove this, create a new movie clip, give it an instance name of scrollingMovieclip and add the following code to the first frame of the main timeline:

var blur=new flash.filters.BlurFilter(3,3,3) //guassian blur
trace(scrollingMovieclip.cacheAsBitmap) //outputs 'true'

When all of the filters effects are removed from a movie clip the cacheAsBitmap property will return to its previous state. So for example, if Bitmap Caching is turned off for a movie clip but it has filters applied to it, then removing all of those filters from the movie clip will turn Bitmap Caching off again:

trace(scrollingMovieclip.cacheAsBitmap) //outputs 'false'

Loading External Content
Also when you load an external Flash Movie or image into a cached movie clip, using ActionScript, bitmap caching is turned off. This is because a movie clip is totally reset, all variables inside it are deleted, and all child movie clips are removed, all movie clip properties are set back to their default values.

To prove it, try the following code:


This code fixes the onLoad bug, that is that anyMovieclip.onLoad event handler is deleted when loading external content into a movieclip

if(onLoadManager == undefined)
onLoadManager[this] =f
return onLoadManager[this]
MovieClip.prototype.addProperty('onLoad', g_onLoad, s_onLoad)
//when the photo is loaded, show that bitmap caching was turned off

More Stories By Guy Watson

Guy Watson (aka FlashGuru) has been a well-recognized figure in the Flash community for around four years, supporting the community with tutorials and source files, moderating the large Flash community forums, and running his own Flash resource Web site - FlashGuru's MX 101. Guy was one of the two developers that created the award-winning zoom interface for Relevare and now works for Endemol UK, the creative force behind reality television, producing programs such as Big Brother and The Salon. Guy now spends most of his time developing Flash games and applications for high-profile clients such as Channel 5 Television, Ladbrookes, and UK Style.

Comments (24) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

Most Recent Comments
Conference Call 07/07/06 04:45:58 PM EDT

Trackback Added: Conference Call; Conference Call

Drug Rehab 07/07/06 09:19:22 AM EDT

Trackback Added: Drug Rehab; Drug Rehab

Payday Loan 07/05/06 10:59:50 AM EDT

Trackback Added: Payday Loan; Payday Loan

Dental Insurance 07/05/06 10:33:31 AM EDT

Trackback Added: Dental Insurance; Dental Insurance

Data Recovery 07/04/06 08:38:25 AM EDT

Trackback Added: Data Recovery; Data Recovery

Printers 07/02/06 12:24:47 PM EDT

Trackback Added: Printers; Printers

1031 Exchange 07/01/06 02:08:26 PM EDT

Trackback Added: 1031 Exchange; 1031 Exchange

First Aid Kits 07/01/06 03:49:12 AM EDT

Trackback Added: First Aid Kits; First Aid Kits

Car Accident Lawyer 06/30/06 02:25:19 PM EDT

Trackback Added: Car Accident Lawyer; Car Accident Lawyer

Acne 06/25/06 02:22:46 PM EDT

Trackback Added: Acne; Acne

Equity Line Of Credit 06/25/06 07:38:23 AM EDT

Trackback Added: Equity Line Of Credit; Equity Line Of Credit

Forklift 06/25/06 07:22:27 AM EDT

Trackback Added: Forklift; Forklift

Term Life Insurance 06/24/06 04:21:24 AM EDT

Trackback Added: Term Life Insurance; Term Life Insurance

Eye Surgery 06/23/06 06:58:00 PM EDT

Trackback Added: Eye Surgery; Eye Surgery

Relocation 06/23/06 06:35:57 PM EDT

Trackback Added: Relocation; Relocation

Payday Loan 06/23/06 06:33:04 PM EDT

Trackback Added: Payday Loan; Payday Loan

Payday Loan 06/23/06 03:15:54 PM EDT

Trackback Added: Payday Loan; Payday Loan

Relocation 06/23/06 03:10:34 PM EDT

Trackback Added: Relocation; Relocation

Distance Education 06/23/06 01:29:59 AM EDT

Trackback Added: Distance Education; Distance Education

Relocation 06/22/06 09:36:41 PM EDT

Trackback Added: Relocation; Relocation

Vasectomy 06/22/06 12:31:50 PM EDT

Trackback Added: Vasectomy; Vasectomy

Aeon 05/27/06 03:21:41 AM EDT

This tutorial is full of syntax errors.
Functions aren't terminated properly, statements aren't properly closed with semi-colons ;.
Needs amendment.

eddyC 02/19/06 07:05:15 PM EST

Hi "noname", I was searching for a solution to this problem and found out you've had the same tysRect-problem... Have you solved it by now? :-) TIA!

noname 01/05/06 06:00:11 PM EST

hey, i just took a shot at the example in "Cover Story: How to Increase the Frame Rates of Your Flash Movies": "Scrolling Large Amounts of Text".

Unless i'm doing something incredibly wrong, it's not close to complete the way you have it in the article. Anyway, i think i've narrowed it down and just need the value for one last property: "tysRect", in the scroll() function.

what is this supposed to be set to??? is there a working fla anywhere?


IoT & Smart Cities Stories
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
In an era of historic innovation fueled by unprecedented access to data and technology, the low cost and risk of entering new markets has leveled the playing field for business. Today, any ambitious innovator can easily introduce a new application or product that can reinvent business models and transform the client experience. In their Day 2 Keynote at 19th Cloud Expo, Mercer Rowe, IBM Vice President of Strategic Alliances, and Raejeanne Skillern, Intel Vice President of Data Center Group and G...
DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT staff augmentation services for software technology providers. By providing clients with unparalleled niche technology expertise and industry experience, Chetu has become the premiere long-term, back-end software development partner for start-ups, SMBs, and Fortune 500 companies. Chetu is headquartered in Plantation, Florida, with thirteen offices throughout the U.S. and abroad.
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
The standardization of container runtimes and images has sparked the creation of an almost overwhelming number of new open source projects that build on and otherwise work with these specifications. Of course, there's Kubernetes, which orchestrates and manages collections of containers. It was one of the first and best-known examples of projects that make containers truly useful for production use. However, more recently, the container ecosystem has truly exploded. A service mesh like Istio addr...
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time t...
SYS-CON Events announced today that DatacenterDynamics has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY. DatacenterDynamics is a brand of DCD Group, a global B2B media and publishing company that develops products to help senior professionals in the world's most ICT dependent organizations make risk-based infrastructure and capacity decisions.