Elliptical button code

xiaoxiao2021-03-06  63

// ******************************************************** *****************************

// ______

// .- "" -.

// / aol /

// | |

// |, .-. .-., |

// |) (__ / / __) (|

// | / // / |

// (@_ (_ ^^ _)

// _) / _______ / __ | iiiiii | __ / _________________________

// (_) @ 8 @ 8 {} <________ | - / iiiiii / - | __________________________>

//) _ / / /

// (@ `--------` aol flash studio.

// ******************************************************** *****************************

@FileName OvalButtonskin.as

@Package

@Description Ellipse button Skin

@Author AOL

@Email jeremy1982@21cn.com

@Create 2004.08.27

@Lastchange 2004.08.27

@History

// ******************************************************** *****************************

Import mx.skins.rectborder;

Import mx.skins.skinelex;

Import mx.core.ext.uiobjectextensions;

Class Ovalbuttonskin Extends RectBorder

{

/ **

@Private

* Symbolname for Object

* /

Static var symbolname: String = "ovalbuttonskin";

/ **

@Private

* Class Used in CreateClassObject

* /

Static var symbolowner: Object = OvalButtonskin;

/ **

* Name of this class

* /

Var classname = "ovalbuttonskin";

Var backgroundcolorname = "buttoncolor";

// var drawowhannel: function;

Function OvalButtonskin ()

{

}

Function init (): void

{

Super.init ();

}

Function size (): void

{

Drawhalorect (Width, Height);

}

Function Drawhalorect (W: Number, H: Number): Void

{

Var borderstyle = getStyle ("Borderstyle"); var themecol = getStyle ("themecolor");

Var emph: boolean = _parent.emphasize;

Clear ();

Switch (BorderStyle)

{

Case "falseup":

IF (EMPH)

{

Drawoval (X, Y, W, H, 0x919999, 100); // Outerborder

Drawoval (X, Y, W, H, THEMECOL, 75); // Outerborder

Drawoval (x 1, y 1, W-2, H-2, [0x333333, 0xfffffff), 85, 0, "Radial");

Drawoval (X 2, Y 2, W-4, H-4, [0x000000, 0xDadada], 100, 0, "Radial");

Drawoval (X 2, Y 2, W-4, H-4, Themecol, 75);

Drawoval (x 3, y 3, w-6, h-6, 0xfffffff, 100); // highlight

Drawoval (X 3, Y 4, W-6, H-7, 0xF8F8F8, 100); // Face

}

Else

{

Drawoval (0, 0, W, H, 0x919999, 100); // Outerborder

Drawoval (1, 1, W-2, H-2, [0xCAD1D1, 0xF7F7F7], 100, 0, "Radial");

Drawoval (2, 2, W-4, H-4, [0x919999, 0xD2DADA], 100, 0, "Radial");

Drawoval (3, 3, W-6, H-6, 0xFfffff, 100); // Highlight

Drawoval (4, 4, W-6, H-7, 0xF8F8F8, 100); // Face

}

Break;

Case "falsedown":

Drawoval (X, Y, W, H, 0x919999, 100); // Outerborder

Drawoval (x 1, y 1, W-2, H-2, [0x333333, 0xFCFCFC], 100, 0, "Radial");

Drawoval (X 1, Y 1, W-2, H-2, Themecol, 50);

Drawoval (X 2, Y 2, W-4, H-4, [0x000000, 0xDadada], 100, 0, "Radial");

Drawoval (X, Y, W, H, THEMECOL, 40); // Outerborder

Drawoval (x 3, y 3, w-6, h-6, 0xfffffff, 100); // highlight

Drawoval (X 3, Y 4, W-6, H-7, Themecol, 20); // Face

Break;

Case "falserollover":

Drawoval (X, Y, W, H, 0x919999, 100); // Outerborder

Drawoval (x, y, w, h, themecol, 50); // Outerborder

Drawoval (X 1, Y 1, W-2, H-2, [0x333333, 0xFfffff], 100, 0, "Radial");

Drawoval (X 2, Y 2, W-4, H-4, [0x000000, 0xDadada], 100, 0, "Radial");

Drawoval (X 2, Y 2, W-4, H-4, Themecol, 50);

Drawoval (x 3, y 3, W-6, H-6, 0xfffff, 100); // highlightdrawoval (x 3, y 4, W-6, H-7, 0xF8F8F8, 100); // Face

Break;

Case "falsedisabled":

Drawoval (0, 0, W, H, 0xC8CCCC, 100); // Outerborder

Drawoval (1, 1, W-2, H-2, 0xF2F2F2, 100);

Drawoval (2, 2, W-4, H-4, 0xD4D9D9, 100);

Drawoval (3, 3, W-6, H-6, 0xF2F2F2, 100); // Face

Break;

Case "Trueup":

Drawoval (X, Y, W, H, 0x999999, 100); // Outerborder

Drawoval (x 1, y 1, W-2, H-2, [0x333333, 0xFCFCFC], 100, 0, "Radial");

Drawoval (X 1, Y 1, W-2, H-2, Themecol, 50);

Drawoval (X 2, Y 2, W-4, H-4, [0x000000, 0xDadada], 100, 0, "Radial");

Drawoval (X, Y, W, H, THEMECOL, 40); // Outerborder

Drawoval (x 3, y 3, w-6, h-6, 0xfffffff, 100); // highlight

Drawoval (X 3, Y 4, W-6, H-7, 0xF7F7F7, 100); // Face

Break;

Case "TrueDown":

Drawoval (X, Y, W, H, 0x999999, 100); // Outerborder

Drawoval (x 1, y 1, W-2, H-2, [0x333333, 0xFCFCFC], 100, 0, "Radial");

Drawoval (X 1, Y 1, W-2, H-2, Themecol, 50);

Drawoval (X 2, Y 2, W-4, H-4, [0x000000, 0xDadada], 100, 0, "Radial");

Drawoval (X, Y, W, H, THEMECOL, 40); // Outerborder

Drawoval (x 3, y 3, w-6, h-6, 0xfffffff, 100); // highlight

Drawoval (X 3, Y 4, W-6, H-7, Themecol, 20); // Face

Break;

Case "Truerollover":

Drawoval (X, Y, W, H, 0x919999, 100); // Outerborder

Drawoval (x, y, w, h, themecol, 50); // Outerborder

Drawoval (X 1, Y 1, W-2, H-2, [0x333333, 0xFfffff], 100, 0, "Radial");

Drawoval (X 1, Y 1, W-2, H-2, Themecol, 40);

Drawoval (X 2, Y 2, W-4, H-4, [0x000000, 0xDadada], 100, 0, "Radial");

Drawoval (X 2, Y 2, W-4, H-4, Themecol, 40);

Drawoval (x 3, y 3, w-6, h-6, 0xfffffff, 100); // highlight

Drawoval (X 3, Y 4, W-6, H-7, 0xF8F8F8, 100); // Face

Break;

Case "Truedisabled": Drawoval (0, 0, W, H, 0xC8CCCC, 100); // Outerborder

Drawoval (1, 1, W-2, H-2, 0xF2F2F2, 100);

Drawoval (2, 2, W-4, H-4, 0xD4D9D9, 100);

Drawoval (3, 3, W-6, H-6, 0xF2F2F2, 100); // Face

}

}

Function Drawoval (X0: Number, Y0: Number, W: Number, H: Number, C, Alpha: Number, Rot: Number, grad: string

{

Var radius = w / 2;

VAR Yradius = H / 2;

VAR x = x0 radius;

VAR Y = Y0 YRADIUS;

IF (arguments.length <3)

{

Return;

}

IF (TypeOf C == "Object") {

VAR alphas = [alpha, alpha];

Var Ratios = [0, 0xFF];

Var sh = h * .7

Var Matrix = {MatrixType: "Box", x: -sh, y: sh, w: w * 2, h: h * 4, r: rot * 0.0174532925199433}

IF (grad == "radial") {

THIS.BEGINGRADIENTFILL ("Radial", C, Alphas, Ratios, Matrix;

} else {

THIS.BEGINGRADIENTFILL ("Linear", C, Alphas, Ratios, Matrix;

}

} else if (c! = undefined) {

This.Beginfill (C, Alpha);

}

// init variables

Var Theta: Number, Xrctrl: Number, Yrctrl: Number, Angle: Number, Anglemid: Number;

VAR PX: Number, Py: Number, CX: Number, Cy: Number;

// if only yradius is undefined, yradius = radius

IF (Yradius == Undefined)

{

Yradius = RADIUS;

}

// Covert 45 Degrees to Radians for Our Calculation

Theta = math.pi / 4;

// Calculate the discance for the control point

XRCTRL = RADIUS / MATH.COS (Theta / 2);

YRCTRL = Yradius / Math.cos (Theta / 2);

// Start on the right side of the circle

Angle = 0;

THIS.MOVETO (X RADIUS, Y);

// this loop Draws the circle in 8 segments

FOR (var i = 0; i <8; i )

{

// increment ou Angles

Angle = Theta;

Anglemid = Angle - (Theta / 2);

// Calculate Our Control Point

CX = x math.cos (anglemid) * xrctrl; cy = y math.sin (anglemid) * yrctrl

// Calculate Our End Point

PX = X Math.cos (ANGLE) * RADIUS;

PY = y math.sin (angle) * yradius;

// Draw the circle segment

This.curveto (CX, CY, PX, PY);

}

IF (c! = undefined)

THIS.Endfill ();

}

Static function classconstruct (): boolean

{

UIObjectExtensions.extensions ();

_Global.skinRegistry ["ovalbuttonskin"] = true;

Return True;

}

Static var classconstructed: boolean = classconstruct ();

Static var uiobjectextensionsionsdependency = uiobjectextensions;

}

Here is a shortcoming that once you change the theme of the component, you cannot use another topic in the same FLA file. Because they are controlled by a global variable. I can only use setStyle () and another. One component can coexist. Macromedia has a lot of defects in the overall component design, not only here. In the design of the base class, there are some major defects in the design of the event model. Time you use Set of MVC mode design.

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

New Post(0)