Use BitmapData as accumulate buffer

Source: Internet
Author: User

Let's edit this post today. As usual, I'll talk a little bit about what is called accumulate buffer and how to use flash to achieve this thing and achieve results.
One. Accumulate buffer: In fact, in the graphics processing in a very much of the cache, it is responsible for the frame rendering after the save, and in the subsequent processing of repeated use. It can achieve such as motion blur (dynamic Blur), Anti-alias (anti-aliasing) and other very mysterious effect. This introduction is simple to construct.

Two. Cut to the point, we use flash 8.0来 imitate accumulate buffer to achieve a very handsome blur effect bar, the final effect can look like media player inside the visual effect Oh! Follow me below.

1. Create a new flash document, and name it casually.
2. On the stage casually do a moving movieclip, the best simple point, we can continue, here I used a few simple tweens made a movement of the stick.
3. Back to the outermost, give this movieclip name stick, and then create a new layer, in the new layer of the first frame to write ActionScript, Stick._visible=false; Because we do not want to let the ball directly render to the screen but let him into the accumulate Buffer, after the completion of this kind of appearance [Step1]
4. Ctr+enter, test, we should not see the ball. OK, then in Ball._visible=false, start our text.

5. The paragraph in Ball._visible=false was supplemented by the following:

Import Flash.display.BitmapData;
Import flash.geom.*;
Import flash.filters.*;

Stick._visible=false;
var accumulatebuffer = new BitmapData (550,400,false,0xff000000);//Create a BitmapData object using these parameters
Attachbitmap (accumulatebuffer,1)//Put Accumulatebuffer on stage, otherwise how can we see the effect?

function Onenterframe () {
Accumulatebuffer.draw (stick)//each frame of the target MovieClip painted to the Accumulatebuffer.
Well, our first step is done, ctrl+enter test, we can already see a movieclip being painted on a accumulatebuffer in succession. Well... It's just not very nice. The following is the source file that completes the first step: Click here to download the source file

With the foundation, the following we take Accumulatebuffer to a show of skill!! Let's implement a result that makes the picture gradually blurred. Add that section of ActionScript to four lines to change to: import Flash.display.BitmapData;
Import flash.geom.*;
Import flash.filters.*;
Stick._visible=false;
var accumulatebuffer = new BitmapData (550,400,false,0xff000000);
var tempbuffer = new BitmapData (550,400,false,0xff000000); Create another cache for BitmapData as obfuscation
var blurfilter = new Blurfilter (2,2,1); Create a filter that blurs the surface
Attachbitmap (accumulatebuffer,1);
function Onenterframe () {
Tempbuffer.draw (Accumulatebuffer)//Accumulatebuffer painting to tmpbuffer for fuzzy processing
Accumulatebuffer.applyfilter (Tempbuffer,tempbuffer.rectangle,new Point (), blurfilter); Write the blurred image back to Accumulatbuffer
Accumulatebuffer.draw (stick);
}

Source files After completing these tasks: Click here to download the source file .

OK, let's test it, is it a feeling of delay and drift? In fact, Accumulatebuffer still have a lot of usage, here is not one by one cases lifted. Here are some of the effects I do with bitmapdata to do accumulatebuffer.
Perform external MC using AC buffer:

Click here to download the source file



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.