Are you using embeded or device fonts? Also, is there a reason you are using UITextFormat instead of TextFormat? Even when using with a UITextField, 99% of the time using UITextFormat instead of TextFormat is unnecessary and makes thing more complicated.
- Dan Freiman On Feb 4, 2008 9:22 AM, ndkamp <[EMAIL PROTECTED]> wrote: > Thanks for your answer. I know the text and orange background are ok, > but the formats won't show. Are you really getting bold text, what > about the size and color? what if you add: > > format.italic = true, > format.underline = true; > format.font = "Georgia"; > > Do they show? can't get the formats to work. Im using flex beat 3 btw. > thanks. > > --- In [email protected] <flexcoders%40yahoogroups.com>, " > shrikant.patil" <[EMAIL PROTECTED]> > > wrote: > > > > > > hi, > > > > i have tested u r file.... i got a orange backgrounded, vardana, > bold text > > saying that : The quick brown Fox... > > > > i hope it is working fine... > > > > > > ndkamp wrote: > > > > > > I try to apply UITextFormat to an UITextField in a custom component > > > but the new format won't show. what am i doing wrong? > > > > > > package tests.components > > > { > > > import flash.text.TextLineMetrics; > > > import mx.core.UIComponent; > > > import mx.core.UITextField; > > > import mx.core.UITextFormat; > > > > > > public class TestCustomComponent extends UIComponent > > > { > > > private var txt:UITextField; > > > > > > public function TestCustomComponent() > > > { > > > super(); > > > } > > > > > > /* > > > * Create the TextField add some TextFormat and add it to > > > * the displayList. > > > */ > > > override protected function createChildren():void { > > > super.createChildren(); > > > > > > //Use TextFormat and apply some formats > > > var format:UITextFormat = new UITextFormat(this.systemManager); > > > format.font = "Verdana"; > > > format.bold = true; > > > format.color = 0x804020; > > > format.size = 20; > > > > > > //The TextField that should be formated > > > txt = new UITextField(); > > > > > > //The documentation says TextFormat won't be applied > > > //when a styleSheet is in use, naive approach to so set this to > null > > > //is this enough? > > > txt.styleSheet = null; > > > txt.styleName = null; > > > > > > //Apply the TextFormat for defaults and all current Text > > > txt.defaultTextFormat = format; > > > txt.text = "The quick brown Fox..."; > > > this.addChild(txt); > > > > > > } > > > > > > /* > > > * Sets the measures to the width of the text plus some offset > > > */ > > > override protected function measure():void { > > > super.measure(); > > > var metrics:TextLineMetrics = txt.getLineMetrics(0); > > > this.measuredWidth = this.measuredMinWidth = metrics.width + 20; > > > this.measuredHeight = this.measuredMinHeight = metrics.height + 2; > > > } > > > > > > /* > > > * Add a rounded Rectangle at the back of the TextField > > > */ > > > override protected function updateDisplayList(unscaledWidth:Number, > > > unscaledHeight:Number):void { > > > super.updateDisplayList(unscaledWidth, unscaledHeight); > > > this.graphics.beginFill(0xff8800, 1); > > > this.graphics.drawRoundRect(0, 0, unscaledWidth, > unscaledHeight, 10); > > > this.graphics.endFill(); > > > txt.setActualSize(unscaledWidth, unscaledHeight); > > > } > > > } > > > } > > > > > > > > > > > > > -- > > View this message in context: > > http://www.nabble.com/Fail-to-apply-UITextFormat-to-UITextField-in-custom-Component-tp15266357p15267393.html > > Sent from the FlexCoders mailing list archive at Nabble.com. > > > > >

