views:

36

answers:

3

Here's the scenario: I wait for a creationComplete event to occur for an mx:Text object at which point I can access the setTextFormat method of its protected member textField. (textField is not valid until creationComplete.) At that point the text formatting done through textField.setTextFormat increases the height of the text. But the mx:Text itself does not pick up this height change until I call invalidateSize. However, in my case invalidateSize causes the entire text to be redrawn, causing it to flash on the screen. However, if I just manually change the browser window size, the Text height change is made without the text flashing like that. So how could I through a function call accomplish what is taking place when I manually change the browser window size. (I just want mx:Text to pick up the height change accomplished through textfield.setTextFormat.)

A: 

did you tried to put your textfield inside a sprite or movieclip and scale it with your callback?

antpaw
There is an existing complex structure of containers and child objects and so forth that can't be changed. All I know is, that now if I call invalidateSize on the Text object in question, it resizes but with an unacceptable screen flash. If I just resize the browser manually the text control also resizes but without the screen flash. So the question is, what is happenining when I resize the browser manually and how can I do that in code to make the Text object change its height without the ridiculous flash of the text that occurs when I call invalidateSize.
Mark
Parenthetically, I think there's a reason that textfield property of Mx:Text is protected, because its not completely in sync enough with mx:Text to be part of its public interface. But as setTextFormat is only accesible through textField, I have to use it. So somehow now, mx:Text itself needs to be told, "Hey your height has changed because of something that occured in your textField property." But if I do that through Text.invalidateSize(), I get the screen flash which is what I don't want.
Mark
A: 

Well it looks like I came up with something for now.

Mark
Please let us know what you came up with so we can all benefit from what you learned.
invertedSpear
A: 

to invertedspear

I was in fact able to avoid the screen flash by calling

  txt1.invalidateSize();    
  txt1.validateNow();

immediately after the calls to txt1.ui_txtfld().setTextFormat(....)

(ui_txtfld() is how I'm making the protected property textField visible.)

However, elsewhere in my code, it was also necessary to not reference txt1.height directly, but instead,

(txt1.ui_txtfld().textHeight+4)*txt1.scaleY,

as the txt1.textField.textHeight property is valid immediately after changing the height of a textField, whereas txt1.height is not.

Mark