Question

I have a dynamic text box that gets its text from the database. The size of the text is depended on the number of characters in the string I recieve. For example, if I get a 24 chars string (which is the maximum in our database), the text size should be 17p, if I get a 23 chars string, the size should then be 18p and so on. I could create many textFormat instances for each combination, but that wouldn't be elegant. If I have this on my code: var defaultFmt:TextFormat = new TextFormat(); defaultFmt.font = "Comic Sans MS"; defaultFmt.size = 30; defaultFmt.align = TextFormatAlign.CENTER; can I later change the size?

Was it helpful?

Solution

Applying a TextFormat object to either a selection or a TextField.defaultTextFormat only reads data from object once, so you'll have to construct a complete TextFormat object each time you need to apply a custom format. So, both approaches will likely be used, several common text formats can be stored in variables, and a custom-made object can be created each time you need to do something fancy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top