Hadn't thought about using a DataGrid -- interesting point you've brought up here, and I will check it out, thanks...
I did finally find what I was looking for -- className is the property I was needing to carry out what I was trying to do before. It comes back as a string that is the "type" of object I was looking at... My nomenclature was incorrect -- I was dealing with Classes, not Types, and that's why my Google searches didn't work. LOL But thanks for your suggestion -- I will definitely give that a whirl. L. On Tue, Mar 1, 2011 at 6:19 PM, Charlie Hubbard <[email protected]>wrote: > If I had to guess what you're doing I'd say a DataGrid would serve your > purpose much more efficiently than what your doing. Also looks like you > don't have proper separation from your data model and your UI which is going > to lead to code like what you have posted. Your model can carry the dynamic > fees and charges that belong in them. Right now your UI is tightly coupled > to your data model. In fact your UI IS your data model. If you ever wanted > to change the data model or UI you have to rewrite everything. DataGrid > will add rows as your model adds entries. > > Use ItemRenders and ItemEditors to handle editing those values and > rendering the values from your model. Renderers are good for adding things > like '$' and ensuring the result has 2 decimal places. Editors will allow > you to edit the value in the DataGrid. > > Something like the following will help your issue a lot. > > class Fee { > public var name : String; > public var amount : Number; > } > > class Bill { > public var fees : ArrayCollection = new ArrayCollection(); > > public get totalAmount() : Number { > var amount : Number = 0.0; > for each( var fee in fees ) { > amount += fee.amount; > } > return amount; > } > } > > var bill : Bill = new Bill(); > bill.fees.add( new Fee( 8.95, 'Monthly Charge' ) ); > bill.fees.add( new Fee( 15.95, 'Service Charge' ) ); > bill.fees.add( new Fee( 2.95, 'Taxes' ) ); > > dataGrid.dataProvider = bill.fees; > totals.text = String( bill.totalAmount ); > > Now Bill represents the abstract concept of a series of charges. It > contains the data so you don't need to go back into the UI and look through > components trying to piece back together what the bill is. When you do this > it's easy to utilize the Bill class to perform operations like what you're > trying to do. > > Charlie > > On Tue, Mar 1, 2011 at 6:04 PM, Laurence MacNeill <[email protected] > > wrote: > >> I have several Canvases in a VBox, and inside those Canvasses might (or >> might not be) one or more dynamically-created TextInputs, which are >> displaying fee-amounts in them. When someone clicks on the TextInput and >> changes the fee-amount, I want to go through all the TextInput's in that >> particular canvas and total up the fees displayed in all the TextInputs in >> that Canvas... >> >> Easy enough, right? Set a 'change' event listener and use >> Canvas(event.currentTarget.parent).numChildren to loop thru all the children >> in that canvas... >> >> Problem I'm having is that I don't know how to tell what type of child I'm >> looking at -- like if it's a Label, for example, I just want to ignore it >> in that loop. So how do I tell what type of object it is? >> >> Here's an example of my code: >> >> private function feeAmountChanged(event:Event):void { >> var totalFees:Number = 0; >> var tempCanvas:Canvas = Canvas(event.currentTarget.parent); >> for (var i:int=0; i<tempCanvas.numChildren; i++) { >> //Here's where I don't know what to do -- how do I say something >> like the following: >> if (tempCanvas.getChildAt(i) is a TextInput) { >> //Do my summing here, adding it to totalFees >> } >> } >> //place the amount contained in totalFees in the appropriate box down >> below -- unimportant to this discussion right now >> } >> >> >> I know this is a simple, stupid thing. But I just can't figure it out. >> LOL >> >> Thanks, >> Laurence MacNeill >> Mableton, Georgia, USA >> >> > >
