Dybde problem...
HejJeg har et probem med dybden på dette pie chart. Som det kan ses er dybden på chartBackground_mc 1. Så kommer der nogle legends, som har dybderne 2-6. Så genererer jeg nogle wedges, som har dybderne 7-11. Men mit pie chart ligger grafisk UNDER chartBackground_mc.
Jeg håber at nogen kan hjælpe.
VH
Anders
***
// Attaching background
depthCounter = 1;
attachMovie("chartBackground", "chartBackground_mc", depthCounter)
chartBackground_mc._x = 215
chartBackground_mc._y = 56
depthCounter++
// Building legend & pie chart
function buildPieCharts() {
///*** BUILDING LEGENDS ***\\\
for (i=0; i<legendText.length; i++) {
duplicateMovieClip("legend", "legend"+i, depthCounter);
_root["legend"+i]._y = 290+(i*20);
_root["legend"+i].name = legendText[i];
myColor = new Color(_root["legend"+i].square);
myColor.setRGB(colours[i-1]);
depthCounter++;
}
legend._visible = false;
///*** BUILDING PIE CHARTS ***\\\
// Building arrays
amounts = new Array();
for (i=1; i<=5; i++) {
amounts.push(Number(eval("number"+i)));
}
// set your parameters
var radius = 125;
// Radius of circles
var roundplaces = 1;
// number of decimal points in the wedge label
var centerpointx = 200;
// x of center of circle
var centerpointy = 200;
// y of center of circle
var linewidth = 1;
// The stroke thickness
var outlinecolour = "0x000000";
// The color of the outline
var minwedgesize = 40;
// in degrees, the size of a wedge big enough for the label to go inside
var angleoffset = 90;
// by default, the pie begins in the east. This offset rotates the whole pie, in degrees, CCW. A value of 90 starts the pie at "north"
///*** BUILDING PIE A ***\\\
var fromangle = 0;
var toangle = 0;
var totalamount = 0;
// get total
for (zz=0; zz<=amounts.length; zz++) {
totalamount = totalamount+amounts[zz];
}
fromangle = 0;
// loop through array
for (z=0; z<amounts.length; z++) {
toangle = fromangle+((amounts[z]/totalamount)*360);
// create a new clip
_root.createEmptyMovieClip("wedge" add z, depthCounter);
with (_root.wedge add z) {
// draw into the clip
beginFill(colours[z%colours.length], 100);
// fill colour, alpha
lineStyle(linewidth, outlinecolour, 100);
// line width, colour, and transparency
moveTo(centerpointx, centerpointy);
for (i=fromangle-(angleoffset+1); i<toangle-angleoffset; i++) {
lineTo(radius*Math.cos(Math.PI/180*i)+centerpointx, radius*Math.sin(Math.PI/180*i)+centerpointy);
}
endFill();
}
fromangle = toangle;
depthCounter++;
trace(_root["wedge" add z].getDepth())
}
// Functions
function roundme(num, places) {
return Math.round(num*(Math.pow(10, places)))/(Math.pow(10, places));
}
function normalize(x, y) {
x = x%y;
if (x<0) {
x = y+x;
}
return x;
}
}
// Afrunder til X decimaler
Math.roundAt = function(num, base) {
var d = base>0 ? Math.pow(10, base) : 1;
return Math.round(d*num)/d;
// Math.roundAt(tal, 2) - sådan bruges den... :-)
};
stop();
