textfield with padding
I want to create a textfield with a coloured background BUT which some space around the text inside it, so the text doesn't start against the edges of it's background color. I can only textformat the left and right margin, so I found this:
var myFormat:TextFormat = new TextFormat;
myFormat.leftMargin = 40;
myFormat.rightMargin = 40;
var myText:TextField = new TextField;
myText.defaultTextFormat = myFormat;
myText.autoSize = TextFieldAutoSize.CENTER;
myText.y=40
var mySpr:Sprite = new Sprite();
mySpr.graphics.beginFill(0xeeaaaa,1);
mySpr.graphics.drawRect(0,0, myText.width,myText.height+80);
mySpr.graphics.endFill();
addChild(mySpr);
mySpr.addChild(myText);
This uses a coloured Sprite and inside it a textfield which has a space around of of 40 pixels. This textfield is still empty. That's because I've got this complete movieclip inside the Library. I add it through:
var clippy:textfieldpadding = new textfieldpadding()
addChild (clippy)
And what I want to do is place it like this, but than add some text to it.
var clippy:textfieldpadding = new textfieldpadding()
addChild (clippy)
clippy.myText.text = "fake text"
This doesn't work (error #1010). What does?
