This is how I would do it (Others may do it differently)...

Assuming the text fields have id's of bookType and sales:

private function addToArray():void
{
     var newBook:Object = new Object();
     newBook.bookType = bookType.text;
     newBook.sales= bookType.sales;
     bookSales.addItem(newBook);
}

--- In flexcoders@yahoogroups.com, sainath evuri <[EMAIL PROTECTED]>
wrote:
>
> i would like to get the input from the user using textinput boxes and
add them to the arraycollection defined in the code below.
>
> i had defined a method addToArray for serving the purpose.what should
be the type of the arguments passed to that function.
> th code follows:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute">
> <mx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
> [Bindable]
> private var bookSales:ArrayCollection =
> new ArrayCollection(
> [{bookType: "Fiction", Sales: 143},
> {bookType: "Nonfiction", Sales: 189},
> {bookType: "Technology", Sales: 178},
> {bookType: "Self-help", Sales: 224}]);
> private function chartLabel(dataItem:Object, field:String,
> index:int, dataPercent:Number):String
> {
> return dataItem.bookType + " represents \n" + dataPercent +
> "% \n of our sales";
> }
> private function addToArray():void{
>
> }
> ]]>
> </mx:Script>
> <mx:Panel title="Pie Chart">
> <mx:PieChart width="100%" height="100%" dataProvider="{bookSales}"
showDataTips="true">
> <mx:series>
> <mx:PieSeries field="Sales" labelPosition="callout"
> labelFunction="chartLabel">
> <mx:fills>
> <mx:RadialGradient>
> <mx:entries>
> <mx:GradientEntry color="#E9C836"/>
> <mx:GradientEntry color="#AA9127"/>
> </mx:entries>
> </mx:RadialGradient>
> <mx:RadialGradient>
> <mx:entries>
> <mx:GradientEntry color="#A1AECF"/>
> <mx:GradientEntry color="#47447A"/>
> </mx:entries>
> </mx:RadialGradient>
> <mx:RadialGradient>
> <mx:entries>
> <mx:GradientEntry color="#339932"/>
> <mx:GradientEntry color="#339998"/>
> </mx:entries>
> </mx:RadialGradient>
> <mx:RadialGradient>
> <mx:GradientEntry color="#6FB35F"/>
> <mx:GradientEntry color="#497B54"/>
> </mx:RadialGradient>
> </mx:fills>
> </mx:PieSeries>
> </mx:series>
> </mx:PieChart>
> </mx:Panel>
> </mx:Application>
>
>
>       Connect with friends all over the world. Get Yahoo! India
Messenger at http://in.messenger.yahoo.com/?wm=n/
>

Reply via email to