Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Auto resize box of input text

Community Beginner ,
Jan 04, 2024 Jan 04, 2024

Hi, when adding an Input text for someone to write on it, I want the text box auto resize while they are typing, mainly when the user types Intro and the line moves up, but without dissappearing within the text box, but just resizing it.

281
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2024 Jan 04, 2024

Hi.

 

AS3 or HTML5 Canvas?

And can you give a visual example?

Regards,

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 04, 2024 Jan 04, 2024

Hey!

- I'm working with AS3

- I need the text box to auto resize so I can read all the message without being cropped by the same text box (attached sample)

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2024 Jan 04, 2024

are you applying the autoSize property after/as text is entered?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 04, 2024 Jan 04, 2024

No, how can I apply it?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2024 Jan 04, 2024

use a textfield (eg, tf) listener to apply 

 

tf.autoSize="left";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2024 Jan 04, 2024

eg, 

 

tf.addEventListener(Event.CHANGE, f);
 
function f(e:Event):void{
tf.autoSize = "left";
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 05, 2024 Jan 05, 2024
LATEST

Hi.

 

According to the video attached, do you want to resize the text box vertically, right?

Please try something like this:

 

import flash.events.Event;

var initialTFHeight:Number = yourTF.height;
var tfBottomOffset:Number = 50; // make sure the last line will be visible

function resizeTFVertically(e:Event):void
{
	// resize the text box according to the text height but clamping the value to a minimum
	e.currentTarget.height = Math.max(e.currentTarget.textHeight + tfBottomOffset, initialTFHeight);
	e.currentTarget.scrollV = 1;
}

yourTF.multiline = true; // set this value to true here or in the Properties panel
yourTF.addEventListener(Event.CHANGE, resizeTFVertically);

 

 

I hope this helps.

 

Regards,

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines