Are you expecting this to return a reference to a Label instance? tArray[i].ControlName as Label
It will not. "as" is a cast, and requires that an reference to an instance of Label be contained in a variable. If ControlName contains the id of a control instantiated using an mxml tag, then do: this[tArray[i].ControlName].styleName="required"; If you have instantiated the label components dynamically, then that won't work. Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of gregariousgregmi Sent: Thursday, July 03, 2008 4:03 PM To: [email protected] Subject: [flexcoders] Dynamically Set Controls to be Required I have several comboboxes that I want to set to be required based on a login id. I have an array of objects; each object contains a string variable that is the label name of the combo box that I want to be required. The line that sets the styleName to required returns a "Error #1009: Cannot access a property or method of a null object reference." required is defined in the css file. Any ideas? private function getFormControlProperties_Result(evt:ResultEvent):void { if( evt.result == null ) return; tArray = evt.result as Array; for( var i:int=0; i<tArray.length; i++ ){ if( tArray[i].IsRequired == 1 ) (tArray[i].ControlName as Label).styleName="required"; } }

