This content has been marked as final. Show 10 replies
as2 or as3? oops, i see flash 8.
so, you'll have a fair amount of work to do. you'll need to evaluate the default textfield/textformat to determine the text string occupied by each line of text. you can then change font size (and type, if you like) and assign this text back to a multiline textfield without autowrapping so each line is placed as in the default textfield and textformat.
Thanks kglad. Here's the problem, this is actually part of a wysiwyg. I need the text to flow naturally so that it can be changed realtime. I can't break up the text to create consistency. I've got it so that using a common factor, the resulting font sizes are always whole numbers (12, 13, 14) and the preview then jumps in sizes depending on how large the stage is. This causes the preview to always wrap the same way. My main concern is when I have multiple font sizes and the greatest common denominator is like 2 or 1, the preview has to jump in really large increments. I'm wondering if there is another way that I can take 12 point text and preview it at very small incremental sizes on the screen and still have it represent what I'd get on a piece of paper at 12pts. Anymore suggestions?
what are you doing now that prevents text from wrapping differently when font sizes are changed?
Sorry. This has been hard to explain without writing a novel of background information. Here's the deal. Suppose I have a 4x4 inch box on a piece of paper to fill with text. I am developing a wysiwyg in flash to create that text. My application allows the stage to scale to the size of different screens. Therefore, my working area changes and all of my custom components will resize themselves when the stage changes size.
Now, I want to represent a 12pt font on that piece of paper in a 4x4 box. So, I have to figure out how much screen space I have and create an effective dpi to display this box in. Naturally, if that dpi isn't 72 (your screen resolution), then I am scaling the text up or down in point size. So, I found that if I scale the text by a number that forces my changed font sizes to be whole numbers (12 pt becomes 13pt, not 12.5pt), then my wrapping and text placement stays consistent. If I do not, then as I resize the stage, the wrapping jumps back and forth and completely changes the amount of text that can fit in my preview. I figure this must have something to do with flashtype's limitations as far as subpixel placement.
Anyway, the main problem I have with this approach is if I want my real font sizes to be sizes that don't have a large enough greatest common denominator. If I use like 12pt and 17pt fonts, then I wind up with a denominator of 1 and for every 100-200 pixels I change in stage size, I can change my dpi only once. That's not a great solution. I was thinking about this last night and I'm going to try drawing the box at screen resolution and try change _xscale and _yscale. I hope flash 8 can make this legible when scaling by numbers like 300%!
Any other suggestions are very welcome!
i wouldn't use any calculations.
determine which text strings occupy lines 1,2 etc of text in your 4x4. change the size of your textfield. now vary the font size until you get a match of text strings on the correct lines.
How exactly would you go about making that kind of determination?
create a function that will return an array whose elements are the text strings that correspond to each row/line of your original textfield.
you can determine those rows by creating a new textfield (with a small _height property) in this function, using getTextFormat() and setTextFormat() to copy the formatting to your new textfield.
start with the beginning of the original textfield's text string and using a while-loop add text to the new textfield until the textfield's maxscroll property excedes one. then remove, at least, one character from that string until you find a word break (like a space or carriage return). that string constitutes the first line of text from your original textfield. assign that string to your array.
repeat for the remainder of the original textfield's text to find the next line of text etc.
Problem is, this is a wysiwyg... what the user is typing IS the source for the original text string. You are authoring it real-time.
I found that if I create the text box at 72 dpi (screen resolution) and use _xscale and _yscale to fit in my preview, the inconsistencies go away. So the player can render it at subpixel levels, you just need to use whole pt values in your text fields.
Thanks for the help, though.
your first paragraph is irrelevent to my suggestion. but, you're welcome.
Thanks for the suggestion. I understand what you are saying. However, duplicating the creation process was not a very desirable solution as it came with a lot of work and extra room for inconsistencies. However, I may use that concept if I have to synchronize what Flash is doing with some other application or platform.
Thanks again for all of your suggestions, kglad.