I stripped away most of the code and just have all the pertinent parts.
The UIComponent is used because I don't know what class I will be adding to the
application, I have hard coded the string for clarity.
What I am trying to do is dynamically create a textinput spark component,
but running into a problem with the skin class, when I create the UIComponent
the skin is null and I get an exception when I add it to the HGroup.
So thought that if I added the skinclass before I added the element to the
HGroup it would work.
Does anyone have any example code to set the skinclass of a textinput
dynamically?
private function createTextInput():void {
var objClass:Class = getDefinitionByName( "spark.components.TextInput"
) as Class;
var newObject:UIComponent = UIComponent( new objClass() );
var xObject:HGroup = new spark.components.HGroup();
var newLabel:Label = new spark.components.Label();
newLabel[ "text" ] = "First Name:";
newObject["skinClass"] = spark.skins.spark.TextInputSkin;
newObject.percentWidth = 20;
xObject.addElement(newLabel);
xObject.addElement(newObject);
this.addElement( xObject );
}