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

Related Topics: Adobe Flex

Adobe Flex: Article

Flash Player 8: Using Bitmap Caching in Flash

Developers and designers use Flash to do a lot more than just animation

As most of you know, Flash began as a tool for creating vector animations on the web. Flash Player was designed specifically as a lightweight animation viewer to display moving vector objects, which are, in their simplest form, mathematical equations that describe complex shapes made up of points, lines, curves, and fills.

 However, today, developers and designers use Flash to do a lot more than just animation; today, we use Flash for everything from interactive banner ads to games and large applications with complex user interfaces. We are now pushing Flash to its limits, and our frame rates are starting to suffer as we develop content that is more application-centric.

Previous versions of Flash Player showed some obvious performance limitations. The vector renderer inside the player generally coughed and spluttered when it attempted to play Flash applications with a lot of objects on the Stage. This is because the player was not optimized to deal with large amounts of static content. By design, on each frame, Flash Player 7 and previous versions had to update and redraw all the vector objects on the Stage, even if they had not changed. This was an intensive and unnecessary process.

Flash Player 8 addresses these visual performance issues with various improvements and optimizations to the renderer. There are also various new performance-enhancing authoring features in Flash Professional 8, which developers can use to take advantage of these significant changes.

This article will show you how to effectively use these new performance-related features to increase the frame rates of your Flash applications. An intermediate to advanced familiarity with ActionScript and Flash Player functionality is required.

Bitmap Caching
One of the most significant additions to Flash Player 8 has to be bitmap caching. This feature gives developers that are experiencing poor frame rates the power to greatly increase the speed at which large amounts of objects are updated and drawn onto the Stage by the renderer. The renderer is a very important part of Flash Player; it is responsible for everything that you see when you view a Flash application, as it draws all the vector and bitmap data onto the Stage. On each frame, the renderer has to update the Stage and the various objects it contains to reflect any changes that have occurred since the last frame. This process can become quite intensive when the application updates a large amount of information on any given frame. Using this feature gives the developer some control over the amount of work that the renderer has to perform in each frame ­ the less work you give the renderer, the faster and smoother your Flash application will run.

How Bitmap Caching Works
When you turn on bitmap caching for any given movie clip, the player converts the contents of the movie clip into a bitmap, which it generates and then stores in memory alongside the original vector data equivalent. The renderer then displays this bitmap in the place of the vector data by copying the image from memory onto the Stage.

This process essentially makes the renderer's life easier, because it doesn't have to update the movie clip each frame. Instead the process only has to draw the bitmap it generated once, and from then on it simply copies the bitmap from memory onto the Stage. If you change the movie clip or its contents, Flash regenerates the bitmap. There is little or no visual difference when a movie clip has bitmap caching turned on. You may notice a very slight difference because the vector data is snapped to the nearest whole pixel when the bitmap is generated. Bitmap caching also works perfectly well with nested movie clips (movie clips inside movie clips).

To put it in simple terms, by turning on bitmap caching for a movie clip, you are essentially telling Flash Player, "Hey Renderer, I'll make your life a little easier. Freeze this movie clip and display it as a bitmap instead, because this movie clip or its contents are not going to change very often, if at all. They are static."

Turning Bitmap Caching On and Off
Bitmap caching comes in the form of an additional movie clip property that can be switched on or off at author-time using the Property inspector and at runtime using ActionScript, on a per movie clip basis.

Using the Authoring Environment
You can turn bitmap caching on or off for any movie clip in the authoring environment using the Property inspector. Selecting this option disables bitmap caching for all movie clips by default.

To turn bitmap caching on select the desired movie clip instance on Stage by clicking on it. Then, open the Property Inspector from the Window menu. Select Window > Properties > Properties, or use the keyboard shortcut Control + F3.

In the lower right corner of the Property inspector underneath the Blend field, select the Use Runtime Bitmap Caching option for the selected movie clip by clicking the checkbox. Bitmap caching is deselected or turned off by default for all movie clips.

Using ActionScript
You can also turn bitmap caching on and off at runtime using ActionScript. Every movie clip object now has a new ActionScript property called cacheAsBitmap. To turn bitmap caching on for a movie clip, you simply need to set the value of its cacheAsBitmap property to true using the following code:

someMovieClip.cacheAsBitmap=true; //Turn Bitmap Caching ON

Similarly, to turn bitmap caching off for a movie clip using ActionScript, you simply need to set the value of its cacheAsBitmap property to false as follows:

someMovieClip.cacheAsBitmap=false; //Turn Bitmap Caching OFF

You can also determine if a movie clip has bitmap caching turned on by retrieving the value of the cacheAsBitmap property:


When to Use Bitmap Caching
If used correctly, bitmap caching can dramatically reduce the amount of updating instructions that the renderer has to process in every frame, and your applications should, in practice, run a lot quicker and smoother. However, in certain circumstances bitmap caching could have a detrimental effect on the performance of your Flash application, therefore you should choose the movie clips you cache wisely.

Bitmap caching works best for movie clips whose visual appearance doesn't change often or not at all. This is because when a cached movie clip or its contents change, Flash regenerates the bitmap with new data for the area or region of vector data that changed and updates the bitmap held in memory. The renderer then displays the new bitmap.

Bitmap caching also works well for movie clips that contain complex vector data (for example, shapes with lots of curves or gradient fills), as it is quicker for the renderer to copy a bitmap from memory onto the Stage than to draw all those vectors to the Stage.

Every time you rotate, scale, or change the alpha of a cached movie clip, the whole bitmap has to be regenerated. So, turning on bitmap caching for a movie clip that is constantly rotating, changing in size, or contains an animation doesn't make much sense because in every frame the renderer has to update the bitmap to reflect the new appearance of the movie clip as well as redraw it to the Stage, which adds overhead.

On the other hand, bitmap caching works well for both static movie clips and movie clips that move, as long as they don't change visually. It is perfectly fine to move a cached movie clip around the Stage, either with ActionScript or with Timeline animation, because moving it around won't change its visual appearance. The cached bitmap doesn't have to be updated, and the renderer will merely draw the bitmap at its new position.

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 (1) 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
SYS-CON Belgium News Desk 01/18/06 07:20:50 PM EST

As most of you know, Flash began as a tool for creating vector animations on the web. Flash Player was designed specifically as a lightweight animation viewer to display moving vector objects, which are, in their simplest form, mathematical equations that describe complex shapes made up of points, lines, curves, and fills.

@ThingsExpo Stories
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...
"We view the cloud not as a specific technology but as a way of doing business and that way of doing business is transforming the way software, infrastructure and services are being delivered to business," explained Matthew Rosen, CEO and Director at Fusion, in this SYS-CON.tv interview at 18th Cloud Expo (http://www.CloudComputingExpo.com), held June 7-9 at the Javits Center in New York City, NY.
The Founder of NostaLab and a member of the Google Health Advisory Board, John is a unique combination of strategic thinker, marketer and entrepreneur. His career was built on the "science of advertising" combining strategy, creativity and marketing for industry-leading results. Combined with his ability to communicate complicated scientific concepts in a way that consumers and scientists alike can appreciate, John is a sought-after speaker for conferences on the forefront of healthcare science,...
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at Cloud Expo, Ed Featherston, a director and senior enterprise architect at Collaborative Consulting, discussed the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
In his session at Cloud Expo, Alan Winters, U.S. Head of Business Development at MobiDev, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to maximize project result...
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
IoT is rapidly becoming mainstream as more and more investments are made into the platforms and technology. As this movement continues to expand and gain momentum it creates a massive wall of noise that can be difficult to sift through. Unfortunately, this inevitably makes IoT less approachable for people to get started with and can hamper efforts to integrate this key technology into your own portfolio. There are so many connected products already in place today with many hundreds more on the h...
DXWorldEXPO LLC announced today that ICC-USA, a computer systems integrator and server manufacturing company focused on developing products and product appliances, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City. ICC is a computer systems integrator and server manufacturing company focused on developing products and product appliances to meet a wide range of ...
JETRO showcased Japan Digital Transformation Pavilion at SYS-CON's 21st International Cloud Expo® at the Santa Clara Convention Center in Santa Clara, CA. The Japan External Trade Organization (JETRO) is a non-profit organization that provides business support services to companies expanding to Japan. With the support of JETRO's dedicated staff, clients can incorporate their business; receive visa, immigration, and HR support; find dedicated office space; identify local government subsidies; get...
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...
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at @ThingsExpo, James Kirkland, Red Hat's Chief Archi...
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Personalization has long been the holy grail of marketing. Simply stated, communicate the most relevant offer to the right person and you will increase sales. To achieve this, you must understand the individual. Consequently, digital marketers developed many ways to gather and leverage customer information to deliver targeted experiences. In his session at @ThingsExpo, Lou Casal, Founder and Principal Consultant at Practicala, discussed how the Internet of Things (IoT) has accelerated our abilit...
Organizations planning enterprise data center consolidation and modernization projects are faced with a challenging, costly reality. Requirements to deploy modern, cloud-native applications simultaneously with traditional client/server applications are almost impossible to achieve with hardware-centric enterprise infrastructure. Compute and network infrastructure are fast moving down a software-defined path, but storage has been a laggard. Until now.
Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
The best way to leverage your CloudEXPO | DXWorldEXPO presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering CloudEXPO | DXWorldEXPO will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at CloudEXPO. Product announcements during our show provide your company with the most reach through our targeted audienc...
@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.
DXWorldEXPO LLC announced today that the upcoming DXWorldEXPO | CloudEXPO New York event will feature 10 companies from Poland to participate at the "Poland Digital Transformation Pavilion" on November 12-13, 2018.
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...