[As3 Code] window wiping effect (that is, a popular fake game)

Source: Internet
Author: User
Tags addchild
Package
{
Import Flash. display. Bitmap;
Import Flash. display. loader;
Import Flash. display. shape;
Import Flash. display. Sprite;
Import Flash. Events. event;
Import Flash. Events. mouseevent;
Import Flash. Filters. blurfilter;
Import Flash.net. URLRequest;

Public Class Main Extends Sprite
{
Private VaR _ PIC: loader;
Private VaR _ Pic2: loader;
Private VaR _ Bit: bitmap;
Private VaR ABC: SPRITE;
Private VaR Bo: Boolean = False ; // Indicates that the current mouse does not draw

Public Function Main (): void
{
// Load Image
_ PIC = new loader ();
_ Pic2 = new loader ();
_ Pic. Load (New URLRequest ("pp.jpg "));

// Listener load completion event
_ Pic. contentloaderinfo. addeventlistener (event. Complete, loadok );
}
Private Function Loadok (EVT: Event): void
{
// ---- Add a fuzzy image on the upper layer ---------------------

// Define a blur filter
// VaR lvjing: blurfilter = new blurfilter ();
// Lvjing. blurx = 0;
// Lvjing. blury = 0;
// _ Pic. Filters = [lvjing]; // bind the fuzzy settings to the image.

// Add an image with a blur filter to the stage
// This. addchild (_ pic );

// Add the image with the original definition to the stage (the image is on the upper layer of the blurred image)
// _ Bit = new bitmap(evt.tar get. loader. content. bitmapdata );
// This. addchild (_ bit );

// Add a mask layer to the clear image (the mask is used to hide the current image)
// ABC = new sprite ();
// _ Bit. Mask = ABC;
// This. addchild (ABC );


// ---- Add a new graph to the upper layer ----------------------------------------

// Add the source image of the lower layer to the stage
This. addchild (_ pic );

// Load another image and add it to the stage (placed on the upper layer of the previous image)
_ Pic2 = new loader ();
_ Pic2.load (New URLRequest ("pp2.jpg "));
This. addchild (_ pic2 );

// Create a mask object
ABC = new sprite ();

// Apply the mask to the top image to hide it.
_ Pic2.mask = ABC;
This. addchild (ABC );


// Listen to the window wiping action (mouse event) on the stage. When you press and hold the mouse, the window is wiped.
// Press the mouse
This. Stage. addeventlistener (mouseevent. mouse_down, down );

// Move the mouse
This. Stage. addeventlistener (mouseevent. mouse_move, mmove );

// Move the mouse up
This. Stage. addeventlistener (mouseevent. mouse_up, up );
}

// Press the mouse to draw
Private Function Down (EVT: mouseevent): void
{
BO = True ;
}
// Move the mouse up to make the drawing unavailable
Private Function Up (EVT: mouseevent): void
{
BO = False ;
}
// Move the mouse to start drawing
Private Function Mmove (EVT: mouseevent): void
{
If (BO = True )
{
VaR A: Shape = new shape ();
A. Graphics. beginfill (0x00ff00 );
A. Graphics. drawcircle (this. mousex, this. Mousey, 25 ); // Draw where the mouse is located
A. Graphics. endfill ();

// Add the painting to the Mask Layer
ABC. addchild ();
}
}
}
}

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.