Welcome!

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:

isCached=someMovieClip.cacheAsBitmap;

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
Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, will lead you through the exciting evolution of the cloud. He'll look at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering ...
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, will discuss how from store operations...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, will discuss how they b...
SYS-CON Events announced today that mruby Forum will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. mruby is the lightweight implementation of the Ruby language. We introduce mruby and the mruby IoT framework that enhances development productivity. For more information, visit http://forum.mruby.org/.
Digital transformation is changing the face of business. The IDC predicts that enterprises will commit to a massive new scale of digital transformation, to stake out leadership positions in the "digital transformation economy." Accordingly, attendees at the upcoming Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA, Oct 31-Nov 2, will find fresh new content in a new track called Enterprise Cloud & Digital Transformation.
SYS-CON Events announced today that Avere Systems, a leading provider of enterprise storage for the hybrid cloud, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere delivers a more modern architectural approach to storage that doesn't require the overprovisioning of storage capacity to achieve performance, overspending on expensive storage media for inactive data or the overbui...
SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp emp...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, will discuss how given the magnitude of today's applicati...
In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). According to the survey, a quarter of the respondents have already deployed Docker containers and nearly as many (23 percent) are employing the AWS Lambda serverless computing framework. It’s clear: serverless is here to stay. The adoption does come with some needed changes, within both application development and operations. Tha...
SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TAZMO technology and development capabilities in the semiconductor and LCD-related manufacturing fields are among the best worldwide. For more information, visit https://www.tazmo.co.jp/en/.
SYS-CON Events announced today that Avere Systems, a leading provider of hybrid cloud enablement solutions, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere Systems was created by file systems experts determined to reinvent storage by changing the way enterprises thought about and bought storage resources. With decades of experience behind the company’s founders, Avere got its ...
SYS-CON Events announced today that TidalScale will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale is the leading provider of Software-Defined Servers that bring flexibility to modern data centers by right-sizing servers on the fly to fit any data set or workload. TidalScale’s award-winning inverse hypervisor technology combines multiple commodity servers (including their ass...
As hybrid cloud becomes the de-facto standard mode of operation for most enterprises, new challenges arise on how to efficiently and economically share data across environments. In his session at 21st Cloud Expo, Dr. Allon Cohen, VP of Product at Elastifile, will explore new techniques and best practices that help enterprise IT benefit from the advantages of hybrid cloud environments by enabling data availability for both legacy enterprise and cloud-native mission critical applications. By rev...
SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
Amazon is pursuing new markets and disrupting industries at an incredible pace. Almost every industry seems to be in its crosshairs. Companies and industries that once thought they were safe are now worried about being “Amazoned.”. The new watch word should be “Be afraid. Be very afraid.” In his session 21st Cloud Expo, Chris Kocher, a co-founder of Grey Heron, will address questions such as: What new areas is Amazon disrupting? How are they doing this? Where are they likely to go? What are th...
High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, will discuss how by using...