What's wrong with this Class?
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
public class User extends MovieClip
{
public var tf_username :TextField;
public var lb_dptsid :TextField;
public var tf_dptsid :TextField;
public var tf :TextField;
public var tff :TextFormat;
public function User()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init(e:Event):void
{
tf_username = createField(18,'Myriad Pro Cond',"0x092846");
lb_dptsid = createField(9,'Myriad Pro Cond',"0x999999");
tf_dptsid = createField(10, 'Myriad Pro Cond', "0x000000");
lb_dptsid.y = 48;
tf_dptsid.x = 26;
tf_dptsid.y = 47;
tf_username.text = "DPTSID";
lb_dptsid.text = "DPTSID";
tf_dptsid.text = "DPTSID";
addChild(tf_username);
addChild(lb_dptsid);
addChild(tf_dptsid);
var tfx:TextField = new TextField();
tfx.x = 0;
tfx.y = 30;
tfx.text = "this one works though.";
addChild(tfx);
}
private function createField(n:Number,f:String,c:String):TextField
{
var tf:TextField=new TextField();
tf.autoSize=TextFieldAutoSize.LEFT;
tf.selectable=false;
tf.embedFonts=true;
tf.defaultTextFormat=getFormat(n,f,c);
return(tf);
}
private function getFormat(n:Number,f:String,c:String):TextFormat
{
var tff:TextFormat=new TextFormat();
tff.font=f;
tff.size=n;
tff.bold=true;
tff.letterSpacing=0;
tff.color=c;
return(tff);
}
}
}
Any TextField created and added to the stage works, but classing things up to be reuseable chokes. What is wrong with my createField function attempts? I get no compile errors, no run-time errors, and nothing drawn to the screen.
