[Flashcoders] AS3 text fitting in variable box

2008-11-12 Thread Latcho
I need to place project-titles in a multiline textfield, wherof the 
width will be fixed, but sometimes this box might be of less height 
because of more space used by other displaying project elements.
Is there a class that can dynamically regulate the font it's size to fit 
the loaded text to a certian textfield height of a multile textfield?
The project titles are variable in character word length. How is this 
solvable.

Thanks !
Stijn

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 text fitting in variable box

2008-11-12 Thread Joel Stransky
Sounds like a bad design decision to make titles of the same category
various sizes. But I think you can just set the .width property, then set
the .scaleY equal to the .scaleX or visa versa depending on which dimension
is more important.

On Wed, Nov 12, 2008 at 9:40 AM, Latcho [EMAIL PROTECTED] wrote:

 I need to place project-titles in a multiline textfield, wherof the width
 will be fixed, but sometimes this box might be of less height because of
 more space used by other displaying project elements.
 Is there a class that can dynamically regulate the font it's size to fit
 the loaded text to a certian textfield height of a multile textfield?
 The project titles are variable in character word length. How is this
 solvable.
 Thanks !
 Stijn

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
--Joel
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 text fitting in variable box

2008-11-12 Thread Latcho


I'm talking about font size, not stretching a container.
Increasing / decreasing font size to get an optimal fill of a box which 
will have a fixed width and a certain height which can only be 
determined during load time.
I could increase the font size of a textfield in a loop and measure it's 
height on every point increase; when it overflows my wanted box-height I 
take the font size of the  previous step.

Is there an easier way ?
Stijn

Joel Stransky wrote:
Sounds like a bad design decision to make titles of the same category 
various sizes. But I think you can just set the .width property, then 
set the .scaleY equal to the .scaleX or visa versa depending on which 
dimension is more important.


On Wed, Nov 12, 2008 at 9:40 AM, Latcho [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


I need to place project-titles in a multiline textfield, wherof
the width will be fixed, but sometimes this box might be of less
height because of more space used by other displaying project
elements.
Is there a class that can dynamically regulate the font it's size
to fit the loaded text to a certian textfield height of a multile
textfield?
The project titles are variable in character word length. How is
this solvable.
Thanks !
Stijn

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
mailto:Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




--
--Joel


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 text fitting in variable box

2008-11-12 Thread jonathan howe
Is there an important distinction between scaling a TextField object and
changing the font size? Perhaps you are storing the formatting or there are
visual rendering implications or anything?? Otherwise, it seems like Joel's
solution would work nicely to achieve what you want.
-jonathan


On Wed, Nov 12, 2008 at 6:18 PM, Latcho [EMAIL PROTECTED] wrote:


 I'm talking about font size, not stretching a container.
 Increasing / decreasing font size to get an optimal fill of a box which
 will have a fixed width and a certain height which can only be determined
 during load time.
 I could increase the font size of a textfield in a loop and measure it's
 height on every point increase; when it overflows my wanted box-height I
 take the font size of the  previous step.
 Is there an easier way ?
 Stijn

 Joel Stransky wrote:

 Sounds like a bad design decision to make titles of the same category
 various sizes. But I think you can just set the .width property, then set
 the .scaleY equal to the .scaleX or visa versa depending on which dimension
 is more important.

 On Wed, Nov 12, 2008 at 9:40 AM, Latcho [EMAIL PROTECTED] mailto:
 [EMAIL PROTECTED] wrote:

I need to place project-titles in a multiline textfield, wherof
the width will be fixed, but sometimes this box might be of less
height because of more space used by other displaying project
elements.
Is there a class that can dynamically regulate the font it's size
to fit the loaded text to a certian textfield height of a multile
textfield?
The project titles are variable in character word length. How is
this solvable.
Thanks !
Stijn

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
mailto:Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




 --
 --Joel


 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
-jonathan howe
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Fwd: Re: [Flashcoders] AS3 text fitting in variable box]

2008-11-12 Thread Latcho


Hi Joel, Jonathan anf Dave for your answers
Dave could you explain what you mean with a binary search ?
Stijn

David Hershberger wrote:
Text flow of variable-width fonts with word-wrapping is inherently 
messy... there's no way to compute the number of lines with some nice 
math, you just have to run the text-flow machinery and measure the 
result, which is exactly what you have suggested.  I'm pretty certain 
there is nothing built into flash or flex to choose a font size for 
you automatically.


My only suggestion is a speed optimization: use a binary search 
instead of trying every font size.


Dave

On 11/12/08, *Latcho* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



I'm talking about font size, not stretching a container.
Increasing / decreasing font size to get an optimal fill of a box
which will have a fixed width and a certain height which can only
be determined during load time.
I could increase the font size of a textfield in a loop and
measure it's height on every point increase; when it overflows my
wanted box-height I take the font size of the  previous step.
Is there an easier way ?
Stijn

Joel Stransky wrote:

Sounds like a bad design decision to make titles of the same
category various sizes. But I think you can just set the
.width property, then set the .scaleY equal to the .scaleX or
visa versa depending on which dimension is more important.

On Wed, Nov 12, 2008 at 9:40 AM, Latcho [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:

   I need to place project-titles in a multiline textfield, wherof
   the width will be fixed, but sometimes this box might be of
less
   height because of more space used by other displaying project
   elements.
   Is there a class that can dynamically regulate the font
it's size
   to fit the loaded text to a certian textfield height of a
multile
   textfield?
   The project titles are variable in character word length.
How is
   this solvable.
   Thanks !
   Stijn

   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
mailto:Flashcoders@chattyfig.figleaf.com
   mailto:Flashcoders@chattyfig.figleaf.com
mailto:Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
--Joel



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
mailto:Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders





___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Fwd: Re: [Flashcoders] AS3 text fitting in variable box]

2008-11-12 Thread Latcho


Joel, Jonathan and Dave: thanks for your answers
Dave could you explain what you mean with a binary search ? I haven't 
got a clue.

Stijn

David Hershberger wrote:
Text flow of variable-width fonts with word-wrapping is inherently 
messy... there's no way to compute the number of lines with some nice 
math, you just have to run the text-flow machinery and measure the 
result, which is exactly what you have suggested.  I'm pretty certain 
there is nothing built into flash or flex to choose a font size for 
you automatically.


My only suggestion is a speed optimization: use a binary search 
instead of trying every font size.


Dave

On 11/12/08, *Latcho* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



I'm talking about font size, not stretching a container.
Increasing / decreasing font size to get an optimal fill of a box
which will have a fixed width and a certain height which can only
be determined during load time.
I could increase the font size of a textfield in a loop and
measure it's height on every point increase; when it overflows my
wanted box-height I take the font size of the  previous step.
Is there an easier way ?
Stijn

Joel Stransky wrote:

Sounds like a bad design decision to make titles of the same
category various sizes. But I think you can just set the
.width property, then set the .scaleY equal to the .scaleX or
visa versa depending on which dimension is more important.

On Wed, Nov 12, 2008 at 9:40 AM, Latcho [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:

   I need to place project-titles in a multiline textfield, wherof
   the width will be fixed, but sometimes this box might be of
less
   height because of more space used by other displaying project
   elements.
   Is there a class that can dynamically regulate the font
it's size
   to fit the loaded text to a certian textfield height of a
multile
   textfield?
   The project titles are variable in character word length.
How is
   this solvable.
   Thanks !
   Stijn

   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
mailto:Flashcoders@chattyfig.figleaf.com
   mailto:Flashcoders@chattyfig.figleaf.com
mailto:Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
--Joel



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
mailto:Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders





___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] AS3 text fitting in variable box

2008-11-12 Thread David Hershberger
No problem.

A binary search is an order log(N) method for finding something in an
ordered list of elements, as compared to linear search, which is order N.
(N is the number of elements, in this case, font sizes you are willing to
use.)

You have a sequence of font sizes.  For each size, it either makes the
TextField too tall, or it doesn't.  You want to find the biggest size which
isn't too tall.

The linear approach is to start from one end of the font size list or the
other and try sizes one by one until the TextField height crosses the
threshold.

The binary approach is to try both ends first, say 1 and 50.  If 1 is too
big or 50 is too small, you already have your answer.  If not, try the
middle: 25.  If 25 is too big, move your idea of biggest down to 25, and
try the middle between 25 and 1: 13.  Maybe 13 is too small, so change your
idea of smallest to 13.  Then try the middle between 13 and 25: 19, and so
on.  Once the two ends (smallest and biggest) are adjacent elements (say
one point difference in font size), the one marked smallest is your
answer.

Binary search is only a little more complicated than a linear search to
implement, and if you are searching over a large number of font sizes, the
savings can be significant.  If it's just 4 or 5 font sizes it's probably
not worth the trouble.

Binary search is a very classic computer science algorithm, so I'm sure you
can find good descriptions on the web.
Dave

On 11/12/08, Latcho [EMAIL PROTECTED] wrote:

  Hi Joel, Jonathan anf Dave for your answers
 Dave could you explain what you mean with a binary search ?
 Stijn

 David Hershberger wrote:

 Text flow of variable-width fonts with word-wrapping is inherently messy...
 there's no way to compute the number of lines with some nice math, you just
 have to run the text-flow machinery and measure the result, which is exactly
 what you have suggested.  I'm pretty certain there is nothing built into
 flash or flex to choose a font size for you automatically.

 My only suggestion is a speed optimization: use a binary search instead of
 trying every font size.

 Dave

 On 11/12/08, Latcho [EMAIL PROTECTED] wrote:


 I'm talking about font size, not stretching a container.
 Increasing / decreasing font size to get an optimal fill of a box which
 will have a fixed width and a certain height which can only be determined
 during load time.
 I could increase the font size of a textfield in a loop and measure it's
 height on every point increase; when it overflows my wanted box-height I
 take the font size of the  previous step.
 Is there an easier way ?
 Stijn

 Joel Stransky wrote:

 Sounds like a bad design decision to make titles of the same category
 various sizes. But I think you can just set the .width property, then set
 the .scaleY equal to the .scaleX or visa versa depending on which dimension
 is more important.

 On Wed, Nov 12, 2008 at 9:40 AM, Latcho [EMAIL PROTECTED] mailto:
 [EMAIL PROTECTED] wrote:

I need to place project-titles in a multiline textfield, wherof
the width will be fixed, but sometimes this box might be of less
height because of more space used by other displaying project
elements.
Is there a class that can dynamically regulate the font it's size
to fit the loaded text to a certian textfield height of a multile
textfield?
The project titles are variable in character word length. How is
this solvable.
Thanks !
Stijn

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
 mailto:Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




 --
 --Joel


 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 text fitting in variable box

2008-11-12 Thread Latcho
The distinction is that wordwrapping should be optimal, as you know when 
you increase / decrease a fontsize, the wordwrapping changes.


jonathan howe wrote:

Is there an important distinction between scaling a TextField object and
changing the font size? Perhaps you are storing the formatting or there are
visual rendering implications or anything?? Otherwise, it seems like Joel's
solution would work nicely to achieve what you want.
-jonathan


On Wed, Nov 12, 2008 at 6:18 PM, Latcho [EMAIL PROTECTED] wrote:

  

I'm talking about font size, not stretching a container.
Increasing / decreasing font size to get an optimal fill of a box which
will have a fixed width and a certain height which can only be determined
during load time.
I could increase the font size of a textfield in a loop and measure it's
height on every point increase; when it overflows my wanted box-height I
take the font size of the  previous step.
Is there an easier way ?
Stijn

Joel Stransky wrote:



Sounds like a bad design decision to make titles of the same category
various sizes. But I think you can just set the .width property, then set
the .scaleY equal to the .scaleX or visa versa depending on which dimension
is more important.

On Wed, Nov 12, 2008 at 9:40 AM, Latcho [EMAIL PROTECTED] mailto:
[EMAIL PROTECTED] wrote:

   I need to place project-titles in a multiline textfield, wherof
   the width will be fixed, but sometimes this box might be of less
   height because of more space used by other displaying project
   elements.
   Is there a class that can dynamically regulate the font it's size
   to fit the loaded text to a certian textfield height of a multile
   textfield?
   The project titles are variable in character word length. How is
   this solvable.
   Thanks !
   Stijn

   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   mailto:Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




--
--Joel

  

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders






  


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 text fitting in variable box

2008-11-12 Thread David Hershberger
Text flow of variable-width fonts with word-wrapping is inherently messy...
there's no way to compute the number of lines with some nice math, you just
have to run the text-flow machinery and measure the result, which is exactly
what you have suggested.  I'm pretty certain there is nothing built into
flash or flex to choose a font size for you automatically.

My only suggestion is a speed optimization: use a binary search instead of
trying every font size.

Dave

On 11/12/08, Latcho [EMAIL PROTECTED] wrote:


 I'm talking about font size, not stretching a container.
 Increasing / decreasing font size to get an optimal fill of a box which
 will have a fixed width and a certain height which can only be determined
 during load time.
 I could increase the font size of a textfield in a loop and measure it's
 height on every point increase; when it overflows my wanted box-height I
 take the font size of the  previous step.
 Is there an easier way ?
 Stijn

 Joel Stransky wrote:

 Sounds like a bad design decision to make titles of the same category
 various sizes. But I think you can just set the .width property, then set
 the .scaleY equal to the .scaleX or visa versa depending on which dimension
 is more important.

 On Wed, Nov 12, 2008 at 9:40 AM, Latcho [EMAIL PROTECTED] mailto:
 [EMAIL PROTECTED] wrote:

I need to place project-titles in a multiline textfield, wherof
the width will be fixed, but sometimes this box might be of less
height because of more space used by other displaying project
elements.
Is there a class that can dynamically regulate the font it's size
to fit the loaded text to a certian textfield height of a multile
textfield?
The project titles are variable in character word length. How is
this solvable.
Thanks !
Stijn

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
mailto:Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




 --
 --Joel


 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders