-
效果有参考一下国外的饼图,不过他的代码,注释等我也看不懂,英文不懂,所以我就写个中文的好了。大家完全可以根据我的代码改出更多的效果来。
编程水平有限,大家谅解一下,不过能正常运行。
http://www.yes028.com/amu/ok.swf
增加了xml配置文件,可以直接修改xml文件以达到直接使用的目的。
默认数据来源为piedata.xml但是可以在页面中修改这个数据来源。
如下:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="600">
<param name="movie" value="ok.swf?piedata=piedata.asp" />
<param name="quality" value="high" />
<embed src="ok.swf?piedata=piedata.asp" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="600"></embed>
</object>
在代码中swf文件名后加上参数?piedata=piedata.asp则可以修改数据来源为piedata.asp。
代码一次发不下,下面回贴再发。
以下是引用片段:
//缩放舞台并不缩放内容,将内容定位于舞台的左上角;
Stage.align = "TL";
Stage.scaleMode = "noScale";
_quality = "BEST";
import mx.transitions.Tween;
import mx.transitions.easing.*;
//全局
//所有数据
var pie_num:String = "20,15,8,50,55,100,100,190";
//所有数据名称
var pie_name:String = "四川,重庆,云南,贵州,山西,湖南,上海,北京,广州";
//是否显示数据名称与百分比值
var show_name:String = "true,false,false,true,false,true,true,true"
//所有颜色
var colorstr:String = "0xFF0F00,0xFF6600,0xFF9E01,0xFCD202,0xF8FF01,0xB0DE09,0x04D215,0x0D8ECF,0xFF1F11";
//所有开始位置
var defaultsate:String = "false,false,false,false,false,false,false,true";
//公共变量
x0 = 210;//圆点坐标x(数字)
y0 = 135;//圆点坐标y(数字)
z = 150;//圆长轴(>0)
d = 90;//圆短轴(>0)
w = 150;//环宽(>0,<长轴)
h = 20;//饼高(>=0)
movew = 15;//移动距离(>0)
alpha = 100;//点击之后的透明度(0-100)
mcalpha = 100;//默认所有开始透明度(0-100)
showorder = true;//是否显示竖向排列表(true,false)
orderx = 400;//竖向排列表起始x(数字)
ordery = 70;//竖向排列表起始y(数字)
orderxy = 6;//竖向排列表竖向间隔(>0)
linecolor = 0xcccccc;//指示线颜色(十六进制颜色)
linealpha = 100;//指示线透明度(0-100)
titleline = 20; //指示线长度(>0 || 0<)
fontcolor = 0xFF0000;//文字颜色(十六进制颜色)
percentshow = "font";//是否显示百分值四个值(font文字,num百分值,all都显示,none不显)
orderfontcolor = 0x222222;//左边竖向排列文字颜色(十六进制颜色)
dark = 1.43;//深色系数(>1如1.43默认)
//以下为三个饼图示例
//第一个参数为影片名,第二个为深度群
drawpie("amu",1,
pie_num,pie_name,titleline,linecolor,linealpha,orderfontcolor,percentshow,fontcolor,colorstr,defaultsate,show_name,
x0,y0,z,d,w,h,movew,alpha,mcalpha,dark,
showorder,orderx,ordery,orderxy);
drawpie("vapr",2,
"15,30,60,90","<b>好</b>,不好,一般,差,太差了",0,0xcccccc,0,0x000000,"all",0x666666,"0x0D8ECF,0x04D215,0xB0DE09,0xF8FF01,0xFF9E01,0xFF6600,0xFF1F11","true,true,false,false","true,true,true,false",
160,380,70,70,50,2,15,100,100,1.5,
true,20,340,13);
drawpie("kiss",3,
"30,50,290,70,50,10","Flash,Html,Javascript,Asp,PHP,C#",10,0x999999,100,0x000000,"none",0xff6600,"0x0D8ECF,0x04D215,0xB0DE09,0xF8FF01,0xFF9E01,0xFF6600,0xFF1F11","false,false,false,false,false,false,false","false,false,false,false,false,false,false",
470,300,100,60,60,20,15,50,100,1.15,
false,280,250,28);
drawpie("kisss",4,
"242,332,171,116,106,224","Flash,Html,Javascript,Asp,PHP,C#",10,0x999999,100,0x000000,"all",0xff6600,"0x0D8ECF,0x04D215,0xB0DE09,0xF8FF01,0xFF9E01,0xFF6600,0xFF1F11","false,false,false,false,false,false,false","true,true,true,true,true,true,true",
370,520,60,40,40,10,15,50,100,1.15,
true,515,480,3);
function drawpie(mcname:String, depth:Number,
pie_num:String, pie_name:String, titleline:Number, linecolor:Number,linealpha:Number, orderfontcolor:Number,percentshow:String, fontcolor:Number, colorstr:String, defaultsate:String, show_name:String,
x0:Number, y0:Number, z:Number, d:Number, w:Number, h:Number, movew:Number, alpha:Number, mcalpha:Number, dark:Number,
showorder:Boolean, orderx:Number, ordery:Number, orderxy:Number):Void{
arr_n = pie_num.split(",");
arr_total=0;
for(m=0;m<arr_n.length;m++){
arr_total+=Number(arr_n[m]);
}
var arr_name = new Array();
arr_name = pie_name.split(",");
var arr_showname = new Array();
arr_showname = show_name.split(",");
var arr_num = new Array();
var arr_percent = new Array();
duof = 0;
for(m=0;m<arr_n.length;m++){
if(m==arr_n.length-1){
duo = 360-duof;
arr_num[m]= duo.toString();
}else{
duo = Math.round((Number(arr_n[m])*360)/arr_total);
duof = duof+duo;
arr_num[m]= duo.toString();
}
arr_percent[m] = Math.round((Number(arr_n[m])*100)/arr_total*100)/100;
}
//分割数据
var arr_color = colorstr.split(",");
var arr_defaultstate = defaultsate.split(",");
//所有扇环的中间度
var arr_middle:Array = new Array();
//生成所有的扇环的中间度,用来确定深度
var xx:Number=-90;
var arr_a:Array = new Array();//记录每一扇环的开始度与结束度
for(m=0; m<arr_num.length;m++){
a0=xx;
a=Number(a0)+Number(arr_num[m]);
arr_a.push([a0,a]);
xx=a;
if(a-a0>180){
arr_middle[m] = 0.001;
}else{
if((a-a0)/2+a0<=180 && (a-a0)/2+a0>=0){
//本mc的中间角度与90度的差值(这儿我们确定谁与90度差值的绝对值最小就排在最前面)
arr_middle[m] = Math.abs(90-((a-a0)/2+a0));
}else if((a-a0)/2+a0>180 && (a-a0)/2+a0<=270){
arr_middle[m] = (Math.abs((a-a0)/2+a0-180)+500);
//本mc的中间角度与180度的差值(这儿我们确定谁与90度差值的绝对值最大就排在最前面)
}else if((a-a0)/2+a0>=-90 && (a-a0)/2+a0<0){
arr_middle[m] = (Math.abs((a-a0)/2+a0-360)+500);
//本mc的中间角度与270度的差值(这儿我们确定谁与90度差值的绝对值最大就排在最前面)
}
}
//trace(m+":"+arr_middle[m]);
}
//trace(arr_a[0][0]);
//扇环排序
arr_middle = arr_middle.sort(Array.NUMERIC|Array.RETURNINDEXEDARRAY);//重排序,让原来的数组值从小到大排列,但数组的索引不变。
//arr_middle.reverse();
//
for(m = 0; m<arr_middle.length; m++){
//绘出竖向方块链接------------------------------------------------------------------------
if(showorder){
_root.createEmptyMovieClip(mcname+arr_middle[m]+"icon_mc",(5-m)*22+depth*10+1);
mc = this[mcname+arr_middle[m]+"icon_mc"];
color = parseInt(arr_color[arr_middle[m]]);
beginx = orderx;
beginy = ordery;
jianxy = orderxy+12;
mc.beginFill(color, 100);
mc.lineStyle(1, darkcolor(color,dark), 100, true, "none");
mc.moveTo(beginx,arr_middle[m]*jianxy+beginy);
mc.lineTo(beginx+12,arr_middle[m]*jianxy+beginy);
mc.lineTo(beginx+12,arr_middle[m]*jianxy+beginy+12);
mc.lineTo(beginx,arr_middle[m]*jianxy+beginy+12);
mc.endFill();
var label:TextField = mc.createTextField("label", 1, beginx+16, arr_middle[m]*jianxy+beginy-3, 0, 0);
label.html = true;
label.autoSize = "left";
label.htmlText = arr_name[arr_middle[m]];
var myformat:TextFormat = new TextFormat();
myformat.font = "Verdana";
myformat.size = 12;
myformat.color = orderfontcolor;
label.setTextFormat(myformat);
}
//---------------------------------------------------------------------
_root.createEmptyMovieClip(mcname+arr_middle[m]+"_mc",(5-m)*22+depth*10);
//当前m应算为arr_middle[m];
drawCircle(this[mcname+arr_middle[m]+"_mc"],
x0, y0, z, d, arr_a[arr_middle[m]][0], arr_a[arr_middle[m]][1], h, w, parseInt(arr_color[arr_middle[m]]),
movew,alpha,mcalpha,arr_defaultstate[arr_middle[m]],
arr_percent[arr_middle[m]],arr_name[arr_middle[m]],arr_showname[arr_middle[m]],
titleline,linecolor,linealpha,fontcolor,percentshow,dark,
this[mcname+arr_middle[m]+"icon_mc"]);
this[mcname+arr_middle[m]+"_mc"]._alpha=mcalpha;
//---------------------------------------------------------------------
//让点击竖向排列时的效果和点击pie时一样。
if(showorder){
mc.onRelease = this[mcname+arr_middle[m]+"_mc"].onRelease;
}
}
}
所有代码放到影片的时间轴上的一帧中就可以了。
以下是引用片段:
/*
mc为影片名。
x0,y0圆心坐标;w1,w2为长短轴;a0为开始度数,a为结束度数,h为高, hw为环宽,color为十六进制颜色,
movew为移动距离,alpha为透明度(点击之后),mcalpha为原始透明度,movenow为确定默认载入时是否移动出去,
valuepercent为百分比值,arr_name为每项名称,arr_showname确定是否显示名称与值,
titleline显示名称与值的长短位置,linecolor指示线颜色,linealpha指示线透明度,fontcolor文字颜色,percentshow是否显示百分比值,dark深色系数(>1如1.43)
本pie对应竖向排列方块mc名。
*/
function drawCircle(mc:MovieClip,
x0:Number, y0:Number, w1:Number, w2:Number, a0:Number, a:Number, h:Number, hw:Number, color:Number,
movew:Number, alpha:Number, mcalpha:Number, movenow:String,
valuepercent:Number, arr_name:String, arr_showname:String,
titleline:Number, linecolor:Number,linealpha:Number, fontcolor:Number,percentshow:String,dark:Number,
ordermc:MovieClip):Void {
//加减间隔度
step = 1;
//求内长短轴
leichang = w1-hw;
leiduan = w2-(hw*w2/w1);
//深色
hicolor = darkcolor(color,dark);
//---------------------------------
//下面为下面环;
mc.beginFill(color, 100);
//mc.lineStyle(1, color, 100, false, "none");
//外边
mc.moveTo(getPoint(x0, y0+h, w1, w2, a0).x, getPoint(x0, y0+h, w1, w2, a0).y);
k = a0;
while (k<a) {
k += step;
mc.lineTo(getPoint(x0, y0+h, w1, w2, k).x, getPoint(x0, y0+h, w1, w2, k).y);
}
//侧边1
mc.lineTo(getPoint(x0, y0+h, leichang, leiduan, k).x, getPoint(x0, y0+h, leichang, leiduan, k).y);
//内边
while (k>a0) {
k -= step;
mc.lineTo(getPoint(x0, y0+h, leichang, leiduan, k).x, getPoint(x0, y0+h, leichang, leiduan, k).y);
}
//侧边2
mc.lineTo(getPoint(x0, y0+h, leichang, leiduan, a0).x, getPoint(x0, y0+h, leichang, leiduan, a0).y);
mc.endFill();
//--------------------------------
//下边高
//下边外侧边高
if(a0<=0 && a>=0 && a<=180){
//解决90度时外侧面,显示事实为90度,实际为0度,因为我们整个旋转了-90度;
mc.beginFill(hicolor, 100);
mc.moveTo(getPoint(x0, y0+h, w1, w2, a0).x, getPoint(x0, y0+h, w1, w2, a0).y);
k=a0;
while (k<0) {
k += step;
mc.lineTo(getPoint(x0, y0+h, w1, w2, k).x, getPoint(x0, y0+h, w1, w2, k).y);
}
mc.lineTo(getPoint(x0, y0, w1, w2, 0).x, getPoint(x0, y0, w1, w2, 0).y);
while (k>a0){
k -=step;
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
}
mc.endFill();
mc.beginFill(hicolor, 100);
mc.moveTo(getPoint(x0, y0+h, w1, w2, 0).x, getPoint(x0, y0+h, w1, w2, 0).y);
k=0;
while (k<a) {
k += step;
mc.lineTo(getPoint(x0, y0+h, w1, w2, k).x, getPoint(x0, y0+h, w1, w2, k).y);
}
mc.lineTo(getPoint(x0, y0, w1, w2, a).x, getPoint(x0, y0, w1, w2, a).y);
while (k>0){
k -=step;
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
}
mc.endFill();
}else if(a>=180 && a0<=180 && a0>=0){
//解决180度时外侧面,显示事实为270度,实际为180度,因为我们整个旋转了-90度;
mc.beginFill(hicolor, 100);
mc.moveTo(getPoint(x0, y0+h, w1, w2, a0).x, getPoint(x0, y0+h, w1, w2, a0).y);
k=a0;
while (k<180) {
k += step;
mc.lineTo(getPoint(x0, y0+h, w1, w2, k).x, getPoint(x0, y0+h, w1, w2, k).y);
}
mc.lineTo(getPoint(x0, y0, w1, w2, 180).x, getPoint(x0, y0, w1, w2, 180).y);
while (k>a0){
k -=step;
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
}
mc.endFill();
mc.beginFill(hicolor, 100);
mc.moveTo(getPoint(x0, y0+h, w1, w2, 180).x, getPoint(x0, y0+h, w1, w2, 180).y);
k=180;
while (k<a) {
k += step;
mc.lineTo(getPoint(x0, y0+h, w1, w2, k).x, getPoint(x0, y0+h, w1, w2, k).y);
}
mc.lineTo(getPoint(x0, y0, w1, w2, a).x, getPoint(x0, y0, w1, w2, a).y);
while (k>180){
k -=step;
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
}
mc.endFill();
}else if(a0<=0 && a>=180){
//解决同时处于0度和180度的情况
mc.beginFill(hicolor, 100);
mc.moveTo(getPoint(x0, y0+h, w1, w2, a0).x, getPoint(x0, y0+h, w1, w2, a0).y);
k=a0;
while (k<0) {
k += step;
mc.lineTo(getPoint(x0, y0+h, w1, w2, k).x, getPoint(x0, y0+h, w1, w2, k).y);
}
mc.lineTo(getPoint(x0, y0, w1, w2, 0).x, getPoint(x0, y0, w1, w2, 0).y);
while (k>a0){
k -=step;
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
}
mc.endFill();
mc.beginFill(hicolor, 100);
mc.moveTo(getPoint(x0, y0+h, w1, w2, 0).x, getPoint(x0, y0+h, w1, w2, 0).y);
k=0;
while (k<180) {
k += step;
mc.lineTo(getPoint(x0, y0+h, w1, w2, k).x, getPoint(x0, y0+h, w1, w2, k).y);
}
mc.lineTo(getPoint(x0, y0, w1, w2, 180).x, getPoint(x0, y0, w1, w2, 180).y);
while (k>0){
k -=step;
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
}
mc.endFill();
mc.beginFill(hicolor, 100);
mc.moveTo(getPoint(x0, y0+h, w1, w2, 180).x, getPoint(x0, y0+h, w1, w2, 180).y);
k=180;
while (k<a) {
k += step;
mc.lineTo(getPoint(x0, y0+h, w1, w2, k).x, getPoint(x0, y0+h, w1, w2, k).y);
}
mc.lineTo(getPoint(x0, y0, w1, w2, a).x, getPoint(x0, y0, w1, w2, a).y);
while (k>180){
k -=step;
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
}
mc.endFill();
}else{
mc.beginFill(hicolor, 100);
mc.moveTo(getPoint(x0, y0+h, w1, w2, a0).x, getPoint(x0, y0+h, w1, w2, a0).y);
k = a0;
while (k<a) {
k += step;
mc.lineTo(getPoint(x0, y0+h, w1, w2, k).x, getPoint(x0, y0+h, w1, w2, k).y);
}
//mc.lineTo(getPoint(x0, y0+h, w1, w2, a).x, getPoint(x0, y0+h, w1, w2, a).y);
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
while (k>a0) {
k -= step;
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
}
mc.endFill();
}
//下边开始侧面高
mc.beginFill(hicolor, 100);
//mc.lineStyle(1, hicolor, 100, false, "none");
mc.moveTo(getPoint(x0, y0+h, w1, w2, a0).x, getPoint(x0, y0+h, w1, w2, a0).y);
mc.lineTo(getPoint(x0, y0+h, leichang, leiduan, a0).x, getPoint(x0, y0+h, leichang, leiduan, a0).y);
mc.lineTo(getPoint(x0, y0, leichang, leiduan, a0).x, getPoint(x0, y0, leichang, leiduan, a0).y);
mc.lineTo(getPoint(x0, y0, w1, w2, a0).x, getPoint(x0, y0, w1, w2, a0).y);
mc.endFill();
//下面结束侧面高
mc.beginFill(hicolor, 100);
//mc.lineStyle(1, hicolor, 100, false, "none");
mc.moveTo(getPoint(x0, y0+h, w1, w2, a).x, getPoint(x0, y0+h, w1, w2, a).y);
mc.lineTo(getPoint(x0, y0+h, leichang, leiduan, a).x, getPoint(x0, y0+h, leichang, leiduan, a).y);
mc.lineTo(getPoint(x0, y0, leichang, leiduan, a).x, getPoint(x0, y0, leichang, leiduan, a).y);
mc.lineTo(getPoint(x0, y0, w1, w2, a).x, getPoint(x0, y0, w1, w2, a).y);
mc.endFill();
//下面内侧面高
mc.beginFill(hicolor, 100);
//mc.lineStyle(1, hicolor, 100, false, "none");
mc.moveTo(getPoint(x0, y0+h, leichang, leiduan, a0).x, getPoint(x0, y0+h, leichang, leiduan, a0).y);
k = a0;
while (k<a) {
k += step;
mc.lineTo(getPoint(x0, y0+h, leichang, leiduan, k).x, getPoint(x0, y0+h, leichang, leiduan, k).y);
}
mc.lineTo(getPoint(x0, y0, leichang, leiduan, k).x, getPoint(x0, y0, leichang, leiduan, k).y);
while (k>a0) {
k -= step;
mc.lineTo(getPoint(x0, y0, leichang, leiduan, k).x, getPoint(x0, y0, leichang, leiduan, k).y);
}
mc.endFill();
//---------------------------------
//下面为上面环;
mc.beginFill(color, 100);
//mc.lineStyle(1, color, 100, false, "none");
//外边
mc.moveTo(getPoint(x0, y0, w1, w2, a0).x, getPoint(x0, y0, w1, w2, a0).y);
k = a0;
while (k<a) {
k += step;
mc.lineTo(getPoint(x0, y0, w1, w2, k).x, getPoint(x0, y0, w1, w2, k).y);
}
//侧边1
mc.lineTo(getPoint(x0, y0, leichang, leiduan, k).x, getPoint(x0, y0, leichang, leiduan, k).y);
//内边
while (k>a0) {
k -= step;
mc.lineTo(getPoint(x0, y0, leichang, leiduan, k).x, getPoint(x0, y0, leichang, leiduan, k).y);
}
//侧边2
mc.lineTo(getPoint(x0, y0, leichang, leiduan, a0).x, getPoint(x0, y0, leichang, leiduan, a0).y);
mc.endFill();
//--------------------------------------显示名称与值
if(arr_showname=="true"){
mc.beginFill(color, 100);
mc.lineStyle(1, linecolor, linealpha);
mc.moveTo(getPoint(x0, y0, w1, w2, a0+(a-a0)/2).x,getPoint(x0, y0, w1, w2, a0+(a-a0)/2).y);
mc.lineTo(getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).x,getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).y);
mc.endFill();
//trace(mc._name+":"+(a0+(a-a0)/2));
if(a0+(a-a0)/2>0 && a0+(a-a0)/2<90){
var label:TextField = mc.createTextField("label", 1, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).x, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).y, 0, 0);
label.autoSize = "left";
}else if(a0+(a-a0)/2>90 && a0+(a-a0)/2<180){
var label:TextField = mc.createTextField("label", 1, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).x, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).y, 0, 0);
label.autoSize = "right";
}else if(a0+(a-a0)/2>180 && a0+(a-a0)/2<270){
var label:TextField = mc.createTextField("label", 1, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).x, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).y-18, 0, 0);
label.autoSize = "right";
}else if(a0+(a-a0)/2>-90 && a0+(a-a0)/2<0){
var label:TextField = mc.createTextField("label", 1, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).x, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).y-18, 0, 0);
label.autoSize = "left";
}else if(a0+(a-a0)/2==0){
var label:TextField = mc.createTextField("label", 1, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).x, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).y-9, 0, 0);
label.autoSize = "left";
}else if(a0+(a-a0)/2==90){
var label:TextField = mc.createTextField("label", 1, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).x, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).y, 0, 0);
label.autoSize = "center";
}else if(a0+(a-a0)/2==180){
var label:TextField = mc.createTextField("label", 1, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).x, getPoint(x0, y0, w1+titleline, w2+(w2*titleline)/w1, a0+(a-a0)/2).y-9, 0, 0);
label.autoSize = "right";
}
label.html = true;
if(percentshow=="all"){
label.htmlText = arr_name+":"+valuepercent+"%";
}else if(percentshow=="font"){
label.htmlText = arr_name;
}else if(percentshow=="num"){
label.htmlText = valuepercent+"%";
}
var myformat:TextFormat = new TextFormat();
myformat.font = "Verdana";
myformat.size = 12;
myformat.color = fontcolor;
label.setTextFormat(myformat);
label.gridFitType = "pixel";
label.antiAliasType = "advanced";
label.sharpness = -400;
}
//--------------------------------------
//点击移动
mc.onRelease = function(){
//移动方向:度数:
go_a = a0+(a-a0)/2;
//移动距离
go_w = movew;
//trace(this._name);
//trace(this.enabled);
if(mc._x!=0 || mc._y!=0){
myTweeen3=new Tween(mc,"_x",Bounce.easeOut,mc._x,(mc._x - (getPoint(x0,y0,go_w,go_w,go_a).x-x0)),1.5,true);
myTweeen4=new Tween(mc,"_y",Bounce.easeOut,mc._y,(mc._x - (getPoint(x0,y0,go_w,go_w,go_a).x-x0)),1.5,true);
//透明度
myTweeenalpha2=new Tween(mc,"_alpha",Regular.easeOut,mc._alpha,mcalpha,1,true);
var listener3:Object = new Object();
mc.enabled = false;
ordermc.enabled = false;//竖向排列本pie对应的方块mc
listener3.onMotionFinished = function(){
mc.enabled = true;
ordermc.enabled = true;//竖向排列本pie对应的方块mc
}
myTweeen3.addListener(listener3);
//mc._x = mc._x - (getPoint(x0,y0,go_w,go_w,go_a).x-x0);
//mc._y = mc._y - (getPoint(x0,y0,go_w,go_w,go_a).y-y0);
}else{
//到达新点
myTweeen1=new Tween(mc,"_x",Regular.easeOut,mc._x,(getPoint(x0,y0,go_w,go_w,go_a).x-x0),1,true);
myTweeen2=new Tween(mc,"_y",Regular.easeOut,mc._y,(getPoint(x0,y0,go_w,go_w,go_a).y-y0),1,true);
//透明度
myTweeenalpha=new Tween(mc,"_alpha",Regular.easeOut,mc._alpha,alpha,1,true);
var listener1:Object = new Object();
mc.enabled = false;
ordermc.enabled = false;//竖向排列本pie对应的方块mc
listener1.onMotionFinished = function(){
mc.enabled = true;
ordermc.enabled = true;//竖向排列本pie对应的方块mc
}
myTweeen1.addListener(listener1);
}
//trace(this.getDepth());
}
//默认位置(移动)
if(movenow=="true"){
//移动方向:度数:
go_a = a0+(a-a0)/2;
//移动距离
go_w = movew;
myTweeen5=new Tween(mc,"_x",Regular.easeOut,mc._x,(getPoint(x0,y0,go_w,go_w,go_a).x-x0),1,true);
myTweeen6=new Tween(mc,"_y",Regular.easeOut,mc._y,(getPoint(x0,y0,go_w,go_w,go_a).y-y0),1,true);
//透明度
myTweeenalpha=new Tween(mc,"_alpha",Regular.easeOut,mc._alpha,alpha,1,true);
var listener5:Object = new Object();
mc.enabled = false;
ordermc.enabled = false;//竖向排列本pie对应的方块mc
listener5.onMotionFinished = function(){
mc.enabled = true;
ordermc.enabled = true;//竖向排列本pie对应的方块mc
}
myTweeen5.addListener(listener5);
}
}
/*--------------------------------------------------------------------------------------------
x=a*cosX //x、y是椭圆上一点的坐标;a、b分别是长、短轴
y=b*sinX //X是椭圆旋转的角度。
计算椭圆上点的位置函数,x0,y0为圆心;w,h为长短轴;a为度数。返回一个坐标对象,有x和y两个属性。
*/
function getPoint(x0:Number, y0:Number, w:Number, h:Number, a:Number):Object {
a = a*Math.PI/180;
return {x:Math.cos(a)*w+x0, y:Math.sin(a)*h+y0};
}
//--------------------------------------------------------------------------------------
/*--------------------------------------------------------------------------------------------
将颜色加深
原有颜色oldcolor为十六进表示法如:0xff6600;返回同样类型的值
*/
function darkcolor(oldcolor:Number,dark:Number):Number{
//求暗色
if(oldcolor.toString(16).length<6){//防止这个十六进制数的第一位为0;
r = parseInt("0x0"+substring(oldcolor.toString(16), 0, 1));
g = parseInt("0x"+substring(oldcolor.toString(16), 2, 2));
b = parseInt("0x"+substring(oldcolor.toString(16), 4, 2));
}else{
r = parseInt("0x"+substring(oldcolor.toString(16), 0, 2));
g = parseInt("0x"+substring(oldcolor.toString(16), 3, 2));
b = parseInt("0x"+substring(oldcolor.toString(16), 5, 2));
}
//trace("原始rgb:"+r+":"+g+":"+b);
//dark = 1.43;
r=Math.round(r/dark).toString(16);
g=Math.round(g/dark).toString(16);
b=Math.round(b/dark).toString(16);
//trace("新rgb:"+r+":"+g+":"+b);
r.length==1 ? r="0"+r:r;
g.length==1 ? g="0"+g:g;
b.length==1 ? b="0"+b:b;
var hicolor:Number;
hicolor = parseInt("0x"+r.toString(16)+""+g.toString(16)+""+b.toString(16));
r = parseInt("0x"+substring(hicolor.toString(16), 0, 2));
g = parseInt("0x"+substring(hicolor.toString(16), 3, 2));
b = parseInt("0x"+substring(hicolor.toString(16), 5, 2));
return hicolor;
}