Use Flash MX 2004 homemade palette and color components (four)

xiaoxiao2021-03-05  45

Wang Wei Gang, April 2005

The ColorPicker class encapsulates MovieClip of the HS color ring and B brightness slot, and both MovieClip corresponds to both COLORWHEEL and COLORTUBE. Their code is as follows:

import wix *; class wix.ColorWheel extends MovieClip {private var pressed:. Boolean; private var pointer: MovieClip = null; private var mask: MovieClip = null; public function init (p: MovieClip, m: MovieClip) {pointer = p ; mask = m;} public function ColorWheel () {pressed = false; this.onMouseDown = doPress; this.onMouseUp = doRelease; this.onMouseMove = doMove;} private function doPress () {if (enabled) {if (mask. Hittest (_Root._ymouse, true) {pRESSED = true; Domove ();}}} private function Dorelease () {if (enabled) Pressed = false;} private function Domove ()} {IF (Pressed && Pointer && Mask) {if (Mask.hittest (_Root._xmouse, true) {pointer._x = _parent._xmouse; Pointer._y = _parent._ymouse; _parent.UpdateHSB (); } Else {var x1 = _parent._xmouse - this._x - this._width / 2; var y1 = _parent._ymouse - this._y - this._Height / 2; var theta = colorman.getthetabyxyxy (x1, y1); _Parent.sethsb (Theta, 100, null);}}}} public function setBrightness (Brightness: Number) {if (enabled) this._alpha = Brightness;}}

import wix.ColorMan; class wix.ColorTube extends MovieClip {private var pressed: Boolean; private var pointer: MovieClip = null; public function init (p: MovieClip) {pointer = p;} public function ColorTube () {pressed = false; THIS.OnMousedown = dopress; this.onmouseup = doelease; this.onmousemove = Domove;} private function dopress () {if (enabled) {if (this.hittest (_Root._xmouse, _root._ymouse, true) || Pointer. Hittest (_Root._ymouse, true) {pRESSED = true; Domove ();}}} private function Dorelease () {if (enabled) Pressed = false;} private function Domove ()} {IF (PRESSED && POINTER) {Pointer._Y = Math.min (Math.Max ​​(this._y 2, _parent._ymouse), this._y this._height - 2); _parent.UpdateHsb ();}} PUBLIC FUNCTION PAINT (H: Number, s: Number) {IF (enabled) {var B, RGB: Number; this.clear (); for (b = 0; b <= 100; b ) {RGB = ColorMan. HSB2RGBVALUE (H, S, B); this.LinesTyle (2, RGB, 100); this.moveto (2, 203 - b * 2); this.Lineto (19, 203 - b * 2);}}}} ... is not complete ...

转载请注明原文地址:https://www.9cbs.com/read-36675.html

New Post(0)