Help. Auto scale text

  • boydis
  • Born
  • Born
  • boydis
  • Posts: 3

Post 3+ Months Ago

I'm working on a flash project were I have a user input text box and a dynamic text box for the output to allow the user to input text and see it update in real time as they type. I have this working great.

My problem is when the text exceeds the output text box size. From what I found so far, I can have it autosize the text box to fit the text or wrap the text. What I need is for the output text box to auto scale the text to fit within a defined size. In other words the object is to always have the current text auto size as large as possible to fit within the defined area.

Any ideas would be greatly appreciated.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

place a dynamic text on your stage, name it's instance to "dtext"

Code: [ Select ]
dtext._width = 200;
dtext.wordWrap = true;
dtext.autoSize = true;
dtext.text = "i wonder what may happen if the text exceeds the size of the dynamic text";
  1. dtext._width = 200;
  2. dtext.wordWrap = true;
  3. dtext.autoSize = true;
  4. dtext.text = "i wonder what may happen if the text exceeds the size of the dynamic text";

hint: if you dont specify the _width, and the wordWrap it will be one single line.
  • boydis
  • Born
  • Born
  • boydis
  • Posts: 3

Post 3+ Months Ago

I do understand the code you specified. Thanks

I have a dynamic text at 200 x 50 at a fix size with a font size of 36. It has a instance name of Output_txt. I also have a Input text box with an instance name of Input_txt. I use a function to have the Input_txt = Output_txt. I don't want the text field box to change size or word wrap. I just want the text within the box to shrink down as the user input text exceeds the width of the dynamic Output text box.

Does this make sense. Example of how I want the text to scale down or shrink can be found at http://www.stickerjunkie.com. If you type alot of text and exceed the width the text shrinks to width within the text box.

Thanks
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

then u have to reduce the font size until it fits in the dynamic textbox.
textWidth is a property of the text field, and you'll decrease the font size untill dyntext.textWidth < 200; // where 200 is the fixed width.
  • boydis
  • Born
  • Born
  • boydis
  • Posts: 3

Post 3+ Months Ago

Got it. Thanks for your help.
  • dcastro
  • Newbie
  • Newbie
  • dcastro
  • Posts: 6

Post 3+ Months Ago

I have a similar issue but I want the user to be able to specify the font size. Can the font size become a variable?

I have a php form http://www.i15resortcorridorstudy.com/sticky-form.html that writes to a text file.

I want to be able to add form fields to it that allow the user to input a text size for the title and the body.

The final output is http://www.i15resortcorridorstudy.com/final3.html

Thanks!
Dax

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.