Hi
Im trying to create textfield inside my movieclip dynamically (at runtime). So I created a function called “CreateTextField()” which accepts parameters, including the “instanceName” and “txtValue”.
Inside that function is a MovieClip.createTextField() function that takes the values and creates a textfield with the “instanceName” provided and assigns a value to the .text property of the textfield through “txtValue”.
The code compiles. But it just doesnt want to show the textfield.
What Ive got in my constructor is:
CreateTextField("txtNum", "02.", 0, 120, 18, 30, 30);
The CreateTextField function:
public function CreateTextField(instanceName:String, txtValue:String, depth:Number, x:Number, y:Number, width:Number, height:Number)
{
mcButton.createTextField(instanceName, depth, x, y, width, height);
trace(mcButton.instanceName._name);
//format information for the textfield
var txtFieldFormat = new TextFormat();
//format the look of the textfield
txtFieldFormat.bold = true;
txtFieldFormat.color = 0xFFFFFF;
txtFieldFormat.font = "_sans";
//assign a value to the textfield
mcButton.instanceName.text = txtValue;
mcButton.instanceName.setTextFormat(txtFieldFormat);
}
Does any one have an idea as to whats going on. I think it has to do with my instanceName as when i run trace it outputs: undefined
Any help would be great
Cheers