Apply dissolve effect between two bitmaps

Source: Internet
Author: User

Use the As script to parse the transition between two images.

 

Package {
Import flash. display. Sprite;
Import flash. display. Bitmap;
Import flash. display. bitmapdata;
Import flash. Events. event;
Import flash. Geom. Point;

Public class dissolve extends sprite {
Private VaR _ bitmap: bitmapdata;
Private VaR _ bitmap2: bitmapdata;
Private VaR _ image: bitmap;
Private VaR _ seed: number;
Private VaR _ pixelcount: Int = 0;

Public Function dissolve ()
{
// Create a White Rectangle
_ Bitmap = new bitmapdata (stage. stagewidth,
Stage. stageheight,
False, 0 xffffffff );
// Create a black rectangle
_ Bitmap2 = new bitmapdata (stage. stagewidth,
Stage. stageheight,
False, 0xff000000 );
// Bitmapdata object can not be displayed in the window,
// Yet bitmap is accepted.
_ Image = new Bitmap (_ Bitmap );
// Show the white rectangel
Addchild (_ image );
// Set a random number to dissolve between the two bitmap
_ Seed = math. Random () * 100000;
// Begin dissolve when the frame show or say it when you enter the frame.
Addeventlistener (event. enter_frame, onenterframe );
}

Public Function onenterframe (Event: Event): void
{
// Copy 1000 random points from bitmap2 which is the destine bitmap to bitmap
// Which is the start bitmap.
_ Seed = _ bitmap. pixeldissolve (_ bitmap2,
_ Bitmap. rect,
New Point (),
_ Seed,
1000 );
_ Pixelcount + = 1000;
// If we have copied all the points in bitmap2, remove the event.
If (_ pixelcount> _ bitmap. Width * _ bitmap. Height ){
Removeeventlistener (event. enter_frame,
Onenterframe );
}
}
}
}

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.