I have always found that setting the textfield to autosize = "left" and
filling it one letter at a time checking the width at each loop works.  Then
when it goes over the max width, trim it by one letter and display the
field.

Just set the alpha to 0 or something to hide it while you do the loop then
set it back to 100 when it is done.  This way you can also dynamically
control when to show "more" links based on if there is still text left in
the "buffer" or original text string that hasn't been sliced and thrown in
the field.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ryan
Creighton
Sent: Tuesday, May 02, 2006 11:27 AM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] Determine text overflow

 
Hi folks.  Sorry if this issue is old hat - i've been reading through
the archives and can't find a solution.

i have a dynamic text field set to a certain size (picture a dialogue
box at the bottom of an adventure or RPG game).

i'm feeding it text.  i'd like to determine when the text overflows the
box so that i can snip it, save it for later, and display a "more" arrow
prompting the user to press SPACE to keep reading.

My busted methodology-to-date follows.  Thanks for your help.

>Ryan Creighton
Senior Game Developer, CORUS Interactive

>http://www.ytv.com



When i did this a few years ago, i manually added a "/" character
wherever i thought the text should be snipped, and just split the string
into chunks and displayed each chunk on its own.  But this game will be
translated into a few other languages, and i don't trust the translators
to put the delimiter characters in the right places.  Besides, it's a
testing nightmare in a game with a lot of text.

So i built an array of each font character and its width, which i
processed through a function that added up all the widths of the
characters.  When it overflowed, i backed up to the nearest SPACE
character and snipped it there, saving the rest of the text for later.

The trouble is that when i had Flash tell me the widths of each font
character (by filling a text box with each character and measuring them
one-by-one), Flash let each letter get kinda roomy, so my width numbers
were way too large.  So then i hand-measured each character (!!), and my
numbers are still too large ... the font crams the letters together
pretty tightly depending on which letters are next to each other, so my
static width values are no good.  Ack!

i know there's a solution out there! Does anyone have it? (Thanks!!)
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to