[As3 Code] color picker

Source: Internet
Author: User
Package
{
Import Flash. display. Bitmap;
Import Flash. display. bitmapdata;
Import Flash. display. Sprite;
Import Flash. Events. mouseevent;
Import Flash. Geom. colortransform;
Import Flash. Geom. matrix;

Public Class Main Extends Sprite
{
VaR A: SPRITE; // Small Square used to display the pick color
VaR Xin: bitmapdata; // Store the new color.

Public Function Main (): void
{
Init ();
}

Private Function Init (): void
{
// PIC is a background image class, which has been converted to SWC in Flash cs4

VaR Tu: PIC = new PIC (1, 1 );
VaR Tut: bitmap = new Bitmap (TU );
This. addchild (tut );

A = new sprite ();
A. Graphics. beginfill (0x00ff00 );
A. Graphics. drawrect (0, 0, 50, 50 );
A. Graphics. endfill ();
This. addchild ();

// Xin is used to store the currently drawn stage colors.
Xin = new bitmapdata (1, 1, False , 0x0 );
Stage. addeventlistener (mouseevent. mouse_move, qu );
}
// Use the mouse to take the color
Private Function Qu (EVT: mouseevent): void
{
Xin. Draw (stage, new matrix (,-mousex,-Mousey ));
VaR Mycolor: colortransform = new colortransform (); // Store color attributes
Mycolor. Color = Xin. getpixel (0, 0 );
A. Transform. colortransform = mycolor;
}
}
}

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.