Thank you, but the property should exist, so putting it inside string literals is not the intent. I am more concerned about someone refactoring code and renaming "weight" to "grossWeight" and having my application break at compile time vs runtime. So other then this are there any other suggestions.
dataColumn.dataField = "weight"; personObj.weight; // hack to catch rename in future and hopefully be able to find usages where I'd be more likely to find the string literal. --- In [email protected], "Tracy Spratt" <tr...@...> wrote: > > Yes, unless "Person" extends mx:Object, or is explicitly declared as > dynamic, a hard reference to a property name will give a compile error if > that property does not exist. > > > > Tracy Spratt, > > Lariat Services, development services available > > _____ > > From: [email protected] [mailto:[email protected]] On > Behalf Of droponrcll > Sent: Sunday, November 08, 2009 10:07 AM > To: [email protected] > Subject: [SPAM] [flexcoders] Re: Get strong propertyName from object so it > would break at compile time if changed > > > > > > > > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , > "tntomek" <tntomek@> wrote: > > > > Is there a way to get a strong property name from an object? > > > > scenario ... Person class having "weight" property > > > > var column:DataGridColumn > > column.dataField = "weight"; > > > > can i do something like: > > > > column.dataField = Person.weight.getPropertyName(); > > > > ... so that if this "weight" property is renamed one day I would get > compile time warning? > > > > You can look for Person.hasOwnProperty('weight') to see if the property > exists at runtime. If you want a compile-time warning, just put in a hard > reference somewhere to aPerson.weight. > > HTH; > > Amy >

