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;
}
}
}