分享
 
 
 

椭圆形按钮的代码

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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

// ______

// .-" "-.

// / AOL // | |

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

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

// |/ /\ \|

// (@_ (_ ^^ _)

// _ ) \_______\__|IIIIII|__/__________________________

// (_)@8@8{}<________|-\IIIIII/-|___________________________>

// )_/ \ /

// (@ `--------`AOL FLASH STUDIO.

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

// @FileName OvalButtonSkin.as

// @Package

// @Description 椭圆按钮皮肤

// @Author aol

// @Email jeremy1982@21cn.com

// @Create 2004.08.27

// @LastChange 2004.08.27

// @History

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

import mx.skins.RectBorder;

import mx.skins.SkinElement;

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 drawOval: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.emphasized;

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,0xffffff],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,0xffffff,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,0xffffff,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,0xffffff,100);//highlight

drawOval( 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,0xffffff,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,0xffffff,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,0xffffff,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 calculations

theta = Math.PI / 4;

// calculate the distance 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 our 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 UIObjectExtensionsDependency = UIObjectExtensions;

}

这里有一个缺点,就是一旦改变了组件的主题,就不能在同一个fla文件中使用另外一种主题的组件.因为它们是由

一个全局变量来控制.目前我只能用setStyle()和另做一个组件来使它们能够共存.macromedia在整体的组件设计上

是有很多缺陷的,不光在这里.在基类的设计上,还有事件模型的设计上都有一些重大的缺陷.有时间自己用MVC模式设计一套吧.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有