I have been battling this for 2 days now and can’t seem to find any solutions. I am making a flash Statistics chart for my website which pulls the stats from the database and loads them into corresponding arrays in the actionscript. Once all the information is pulled, it goes to the next frame and duplicates the existing stat bars on the flash document depending on how many stats were retrieved. The loaded stats are then calculated to adjust the stat bar heights to fit the grid. So far, everything is working up to this point.
Now for the problem… Directly above each stat bar, I have a text field which I want to fill with the value of the specified stat. The stat text fields are duplicated by the duplicateMovieClip function. For some reason, stat text fields are not visible at all even when using the depthManager function I found in my research.
Here is my code :
var depthCount:Number = 0;
function depthManager() {
depthCount++;
return depthCount;
}
maxValue = function (array) {
mxm = int(array[0]);
for (i=0; i<array.length; i++) {
if (int(array*)>mxm) {
mxm = int(array*);
}
}
return mxm;
};
getHeight = function (statvar) {
totalheight = (((statvar*100)/maxstatview)*(stat_ratio*10))/100;
if (totalheight<1) {
totalheight = 1;
}
return totalheight;
};
imp_bar0._height = 10;
adsshown_bar0._height = 10;
inclicks_bar0._height = 10;
outclicks_bar0._height = 10;
imp_stat0.swapDepths(depthManager());
adsshown_stat0.swapDepths(depthManager());
inclicks_stat0.swapDepths(depthManager());
outclicks_stat0.swapDepths(depthManager());
maximpressions = maxValue(impressions);
maxadsshown = maxValue(adsshown);
maxinclicks = maxValue(inclicks);
maxoutclicks = maxValue(outclicks);
largest = new Array();
largest.push(maximpressions);
largest.push(maxadsshown);
largest.push(maxinclicks);
largest.push(maxoutclicks);
largestvalue = String(maxValue(largest));
divider = 1;
for (d=1; d<largestvalue.length; d++) {
divider = divider*10;
}
maxstatview = Math.ceil(largestvalue/divider)*divider;
statlineinc = maxstatview/10;
var stat_ratio = 20;
for (i=1; i<=10; i++) {
duplicateMovieClip(stat_line, "stat_line"+i, depthManager());
duplicateMovieClip(stat_amount_line, "stat_amount_line"+i, depthManager());
eval("stat_line"+i)._y = stat_line._y-(i*stat_ratio);
eval("stat_amount_line"+i)._y = eval("stat_line"+i)._y-(eval("stat_amount_line"+i)._height/2);
eval("stat_amount_line"+i).text = i*statlineinc;
}
for (i=1; i<thedate.length; i++) {
duplicateMovieClip(imp_bar0, "imp_bar"+i, depthManager());
duplicateMovieClip(adsshown_bar0, "adsshown_bar"+i, depthManager());
duplicateMovieClip(inclicks_bar0, "inclicks_bar"+i, depthManager());
duplicateMovieClip(outclicks_bar0, "outclicks_bar"+i, depthManager());
duplicateMovieClip(imp_stat0, "imp_stat"+i, depthManager());
duplicateMovieClip(adsshown_stat0, "adsshown_stat"+i, depthManager());
duplicateMovieClip(inclicks_stat0, "inclicks_stat"+i, depthManager());
duplicateMovieClip(outclicks_stat0, "outclicks_stat"+i, depthManager());
previousbar = i-1;
eval("imp_bar"+i)._x = eval("outclicks_bar"+previousbar)._x+50;
eval("adsshown_bar"+i)._x = eval("imp_bar"+i)._x+eval("imp_bar"+i)._width;
eval("inclicks_bar"+i)._x = eval("adsshown_bar"+i)._x+eval("adsshown_bar"+i)._width;
eval("outclicks_bar"+i)._x = eval("inclicks_bar"+i)._x+eval("inclicks_bar"+i)._width;
eval("imp_stat"+i)._x = eval("imp_bar"+i)._x;
eval("imp_stat"+i).text = "test";
}
for (i=0; i<thedate.length; i++) {
imp_height = getHeight(impressions*);
adsshown_height = getHeight(adsshown*);
inclicks_height = getHeight(inclicks*);
outclicks_height = getHeight(outclicks*);
eval("imp_bar"+i)._height = imp_height;
eval("adsshown_bar"+i)._height = adsshown_height;
eval("inclicks_bar"+i)._height = inclicks_height;
eval("outclicks_bar"+i)._height = outclicks_height;
_root.eval("imp_stat"+i).swapDepths(depthManager);
trace(eval("imp_stat"+i).getDepth()+": depth");
trace(depthManager());
}
any help is greatly appreciated!