Dynamic Pie Chart - Flash mx2004 Professional

:m:
[font=Courier New]Hi all,[/font]
[font=Courier New]I have a question for you…I’m not able di draw a pie chart dynamically.[/font]
[font=Courier New]I have the Layer1 with a F3DPieChart, 4 input text and a button, I put 4 numer in the 4 inputtext (sum total = 100) and when I press the button I would like to see pie Chart to appear with 4 slices that rappresented my 4 numbers.unfortunately it doesn’t happen.[/font]
[font=Courier New]This is the code on layer1:[/font]

[font=Courier New][QUOTE][/font]
[font=Helv][size=2][font=Courier New]var buttonListener = new Object();[/font]

[font=Courier New]buttonListener.click = function() {[/font]
[font=Courier New]var val;[/font]
[font=Courier New]var dp = new DataProviderClass();[/font]
[font=Courier New]val = _root.t1.text;[/font]
[font=Courier New]dp.addItem ({data:val, color:0xFF0000, label: “1”});[/font]
[font=Courier New]val = _root.t2.text;[/font]
[font=Courier New]dp.addItem ({data:val, color:0x00FF00, label: “2”});[/font]
[font=Courier New]val = _root.t3.text;[/font]
[font=Courier New]dp.addItem ({data:val, color:0x0000FF, label: “3”});[/font]
[font=Courier New]val = _root.t4.text;[/font]
[font=Courier New]dp.addItem ({data:val, color:0xFFFF00, label: “4”});[/font]
[font=Courier New]}[/font]
[font=Courier New]disegno = function(chart){[/font]
[font=Courier New]chart.removeAll(); [/font]
[font=Courier New]chart.setDataProvider(dp);[/font]
[font=Courier New]delete dp;[/font]
[font=Courier New]}[/font]
[font=Courier New]_root.button.addEventListener(“click”, buttonListener);[/font]
[font=Courier New]Any help is apprecciate,[/font]
[font=Courier New]Maryna.[/font]
[/size][/font]

I’m not sure if you are using a component or have another function to draw the chart?

Here’s a basic pie chart example in MX, it may need some tweeking for MX2004Pro, but hopefully it will help!

_root.createTextField('pieInput',1,10,75,250,400);
with(pieInput){
  type='input';
  wordwrap=multiline=background=border=true;
  theformat=getTextFormat();
  theformat.size=20;
  setNewTextFormat(theformat);
  setTextFormat(theFormat);
}

_root.colors=['0xff0000','0x00ff00','0x0000ff','0xffff00','0xff00ff','0x00ffff'];

createTextField('startPie',5,275,250,0,0);
with(startPie){
  type='static';
  selectable=false;
  background=border=autosize=true;
  backgroundColor='0xc6c6c6';
  text='Create Pie Chart';
  _xscale=_yscale=200;
}
createEmptyMovieClip('startP',6);
with(startP){
  lineStyle(1,0x000000,1);
  beginFill(0x000000,1);
  lineTo(_root.startPie._width,0);
  lineTo(_root.startPie._width,_root.startPie._height);
  lineTo(0,_root.startPie._height);
  lineTo(0,0);
 _x=_root.startPie._x;
 _y=_root.startPie._y;
}
_root.startP.onRelease=function(){
  pie=_root.pieInput.text.split(',');
  pieValues=new Array();
  total=0;
  for(p in pie){
    nameValue=pie[p].split('=');
    total+=(nameValue[1]*1);
    pieValues[nameValue[0]]=nameValue[1];
  }
  _root.createEmptyMovieClip('mc',10);
  with(mc){
    lastValue=0;
    lineStyle(1,0x000000,100);
    counter=0;
    for(p in pieValues){
      beginFill(_root.colors[counter],50);
      counter++;
      endValue=Math.round((pieValues[p]/total)*360)+lastValue;
      for(c=lastValue;c<=endValue;c++){
        x=Math.sin(Math.PI/180*c)*200+675;
        y=Math.cos(Math.PI/180*c)*200+250;
        if(c==0){
          moveTo(675,250);
          lineTo(x,y);
        }else if (c==endValue){
          lineTo(x,y);
          lineTo(675,250);
          endFill();
          tx=Math.sin(Math.PI/180*((endValue-lastValue)/2+lastValue))*125+675;
          ty=Math.cos(Math.PI/180*((endValue-lastValue)/2+lastValue))*125+250;
          createTextField('pie'+counter,20+counter,tx,ty,0,0);
          with(eval('pie'+counter)){
            type='static';
            background=border=selectable=false;
            autosize='center';
            text=p;
            theformat=getTextFormat();
            theformat.bold=true;
            theformat.size=15;
            setTextFormat(theformat);
          }
        }else{
          lineTo(x,y);
        }
      }
      lastValue=endValue;
    }
  }
}

createTextField('instructions',7,0,10,500,50);
with(instructions){
  type='static';
  selectable=background=border=false;
  html=multiline=wordwrap=autosize=true;
  htmlText='<p align=\"center\"><font size=\"20\">Enter comma seperated name=value pairs in the text boxes.<br>Example: 1999=100000,2000=125000,2001=135000</font></p>';
}

Thanks for your reply,
I was not so precise, sorry. I’m using DevNet Resource Kit Volume 4.
It allow me to draw 3d Charts.
But I am not able to make it works, I read the on line help but there are very simple example so I can not use them.:a: