Re: [flexcoders] Re: Using arraycollection as text for a flex TextArea Component.
Either the whole entry is null or one of it's properties. Check which is null, and guard your code if null put empty string or whatever you seem fit for it. C From: ZIONIST To: flexcoders@yahoogroups.com Sent: Tuesday, December 27, 2011 5:41 PM Subject: [flexcoders] Re: Using arraycollection as text for a flex TextArea Component. That works well. It actually outputs the contents of the arraycollection in the textarea component. One very small issue though, it outputs the word NULL before the last item in the arraycollection. How do i get rid of that? Below is the update. [Bindable] private var orderColl:ArrayCollection=new ArrayCollection(); /*** Create an object to hold the data ***/ var obj:Object=new Object(); /*** Assign the variables to it ***/ obj.Product=product.text; obj.Price=price.text; obj.Qty=1; obj.OrderNumber=label1.text; /*** Add the object to the list ***/ orderColl.addItemAt(obj, 0); Then i have a TextArea component (id=cart) and i try to assign the arraycollection to it as text like this var txt:String; var n:int=orderColl.length; for (var i:int=0; i < n; i++) { var entry:Object=orderColl.getItemAt(i); txt += entry.OrderNumber + "," + " " + entry.Product + "," + " " + entry.Qty + " " + "Unit" + "(" + "s" + ")" + "," + " " + "$" + entry.Price + " " + "per unit" + "\n\n"; } cart.text = txt;
[flexcoders] Re: Using arraycollection as text for a flex TextArea Component.
That works well. It actually outputs the contents of the arraycollection in the textarea component. One very small issue though, it outputs the word NULL before the last item in the arraycollection. How do i get rid of that? Below is the update. [Bindable] private var orderColl:ArrayCollection=new ArrayCollection(); /*** Create an object to hold the data ***/ var obj:Object=new Object(); /*** Assign the variables to it ***/ obj.Product=product.text; obj.Price=price.text; obj.Qty=1; obj.OrderNumber=label1.text; /*** Add the object to the list ***/ orderColl.addItemAt(obj, 0); Then i have a TextArea component (id=cart) and i try to assign the arraycollection to it as text like this var txt:String; var n:int=orderColl.length; for (var i:int=0; i < n; i++) { var entry:Object=orderColl.getItemAt(i); txt += entry.OrderNumber + "," + " " + entry.Product + "," + " " + entry.Qty + " " + "Unit" + "(" + "s" + ")" + "," + " " + "$" + entry.Price + " " + "per unit" + "\n\n"; } cart.text = txt;
Re: [flexcoders] Re: Using arraycollection as text for a flex TextArea Component.
Actually I should show the last one. try txt += entry.OrderNumber + " " + "," + " " + entry.Produ then the string will have all the entries added not replaced. C From: ZIONIST To: flexcoders@yahoogroups.com Sent: Tuesday, December 27, 2011 6:04 AM Subject: [flexcoders] Re: Using arraycollection as text for a flex TextArea Component. This is what i have come up with some far... Problem is that it only outputs the first entry in the ArrayCollection. So if a client selects more than one item to buy, when he/she previews their selection, they will only see the first entry. Could someone please help me modify this to show all the entries in the ArrayCollection. [Bindable] private var orderColl:ArrayCollection=new ArrayCollection(); /*** Create an object to hold the data ***/ var obj:Object=new Object(); /*** Assign the variables to it ***/ obj.Product=product.text; obj.Price=price.text; obj.Qty=1; obj.OrderNumber=label1.text; /*** Add the object to the list ***/ orderColl.addItemAt(obj, 0); Then i have a TextArea component (id=cart) and i try to assign the arraycollection to it as text like this var txt:String; var n:int=orderColl.length; for (var i:int=0; i < n; i++) { var entry:Object=orderColl.getItemAt(i); txt = entry.OrderNumber + " " + "," + " " + entry.Product + " " + "," + " " + entry.Qty + " " + "," + " " + entry.Price; } cart.text = txt.toString();
[flexcoders] Re: Using arraycollection as text for a flex TextArea Component.
This is what i have come up with some far... Problem is that it only outputs the first entry in the ArrayCollection. So if a client selects more than one item to buy, when he/she previews their selection, they will only see the first entry. Could someone please help me modify this to show all the entries in the ArrayCollection. [Bindable] private var orderColl:ArrayCollection=new ArrayCollection(); /*** Create an object to hold the data ***/ var obj:Object=new Object(); /*** Assign the variables to it ***/ obj.Product=product.text; obj.Price=price.text; obj.Qty=1; obj.OrderNumber=label1.text; /*** Add the object to the list ***/ orderColl.addItemAt(obj, 0); Then i have a TextArea component (id=cart) and i try to assign the arraycollection to it as text like this var txt:String; var n:int=orderColl.length; for (var i:int=0; i < n; i++) { var entry:Object=orderColl.getItemAt(i); txt = entry.OrderNumber + " " + "," + " " + entry.Product + " " + "," + " " + entry.Qty + " " + "," + " " + entry.Price; } cart.text = txt.toString();
[flexcoders] Re: Using arraycollection as text for a flex TextArea Component.
What i want is that after the client has finished selecting the items he/she wants to buy (Items selected make up the arraycollection orderColl), he/she should be able to preview the list of items they selected. so i want the contents of orderColl to be the text of the TextArea. Hope its now clear what am tring to do.
[flexcoders] Re: Using arraycollection as text for a flex TextArea Component.
It looks like you are 'joining' objects, into a string. If you created a product class and provided a suitable toString() method I think that would solve the problem --- In flexcoders@yahoogroups.com, "ZIONIST" wrote: > > Hello Guys i have an arraycollection that is populated dynamically and would > like to use the same arraycollection as text for a TextArea component. Below > is my array collection > > [Bindable] > private var orderColl:ArrayCollection=new ArrayCollection(); > > /*** Create an object to hold the data ***/ > var obj:Object=new Object(); > > /*** Assign the variables to it ***/ > obj.Product=product.text; > obj.Price=price.text; > obj.Qty=1; > obj.OrderNumber=label1.text; > > /*** Add the object to the list ***/ > orderColl.addItemAt(obj, 0); > > Then i have a TextArea component (id=cart) and i try to assign the > arraycollection to it as text like this > > var str:String = orderColl.source.join("\n"); > cart.text = str; > > The result in the textarea is [object object]. Any help guys? >