Styles can override text formating when the parent of a UITextField is invalidated, but only having some formatting overridden is a little weird. Functionality for setting format based on style is in the UITextField class, I think the function is validateNow(), but I not 100% certain about that. For future reference, I asked about font type because embeding fonts incorrectly could account for the described behavior (as I originally understood it), and the rendering engine for device fonts (in very few and specific cases) also has its own quirks.
- Dan Freiman On Feb 4, 2008 10:53 AM, ndkamp <[EMAIL PROTECTED]> wrote: > ok, I found that if i wrap the textField in a sprite and add this in > createChildren, then formatting will be applied correctly: > > var wrapper:Sprite = new Sprite(); > wrapper.addChild(txt); > this.addChild(wrapper); > > Well, i'm not really comfortable with this but I think I need to look > closer at styles, since formats seem to get overriden when a TextField > is add directly to the component...? > > > --- In [email protected] <flexcoders%40yahoogroups.com>, "ndkamp" > <[EMAIL PROTECTED]> wrote: > > > > dan, thanks for your answer. I'm using device and/or embedded fonts, > > but right here I don't really care about the fonts. I'm just puzzled > > why the formatting doesn't seem to work for me. I'm using UITextFormat, > > because of the options it gives me with anti-aliasing and measuring. A > > I tried using TextFormat but that wont help. I did not look at styling > > and skinning, so I'm not sure if the formats get overriden by styles > > in a later stage by the framework. > > > > > > --- In [email protected] <flexcoders%40yahoogroups.com>, > "Daniel Freiman" <FreimanCQ@> wrote: > > > > > > 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 <ndkamp@> 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><flexcoders%40yahoogroups.com>, " > > > > shrikant.patil" <gt_shrikant@> > > > > > > > > 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. > > > > > > > > > > > > > > > > > > > > > > > > >

