# autoSize

**URL:** <https://forum.kirupa.com/t/autosize/263594>\
**Category:** flash\
**Created:** [June 17, 2008, 3:26pm UTC](https://forum.kirupa.com/t/autosize/263594 "2008-06-17T15:26:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![vxd](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vxd](https://forum.kirupa.com/u/vxd)\
**Post date:** [June 17, 2008, 3:26pm UTC](https://forum.kirupa.com/t/autosize/263594/1 "2008-06-17T15:26:06Z")

</div>

I’m using autoSize for my text box, this is working fine.

What I’m trying to do is “autoSize” the background of the text box so no matter how long or short the text box is the background will resize with the text box.

thanks  
Vu

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 17, 2008, 3:43pm UTC](https://forum.kirupa.com/t/autosize/263594/2 "2008-06-17T15:43:07Z")

</div>

you will have to count how many characters there are

know how wide the text box is, wroughly how many characters per line

then tell an MC to change size to fit the text…

I have code myself, however I’d rather watch you sweat

as apparantly you learn by working it out yourself

---

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [June 17, 2008, 4:30pm UTC](https://forum.kirupa.com/t/autosize/263594/3 "2008-06-17T16:30:11Z")

</div>

just do:

```auto

background._width = textbox._width;

```

---

<div class="post-metadata">

**Author:** ![vxd](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vxd](https://forum.kirupa.com/u/vxd)\
**Post date:** [June 17, 2008, 4:32pm UTC](https://forum.kirupa.com/t/autosize/263594/4 "2008-06-17T16:32:16Z")

</div>

I’m still an amateur in AS so I wouldn’t know where to begin.

How about I get some “KEY” actionscript words so I know where to start.

The characters are going to very depending on what information is provided. Should I estimate the maximum amount?

Thanks  
vu

---

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [June 17, 2008, 4:34pm UTC](https://forum.kirupa.com/t/autosize/263594/5 "2008-06-17T16:34:06Z")

</div>

you dont need to estimate how many characters are in the text box. Just set the width of the background equal to the width of the text box.

---

<div class="post-metadata">

**Author:** ![vxd](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vxd](https://forum.kirupa.com/u/vxd)\
**Post date:** [June 17, 2008, 4:34pm UTC](https://forum.kirupa.com/t/autosize/263594/6 "2008-06-17T16:34:41Z")

</div>

[quote=mrwicked;2344371]just do:  
ActionScript Code:  
[LEFT][COLOR=#0000FF]background[/COLOR].[COLOR=#0000FF]\_width[/COLOR] = textbox.[COLOR=#0000FF]\_width[/COLOR];  
[/LEFT]

[/quote]  
Thanks mrwicked i’ll try it now

---

<div class="post-metadata">

**Author:** ![vxd](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vxd](https://forum.kirupa.com/u/vxd)\
**Post date:** [June 17, 2008, 4:37pm UTC](https://forum.kirupa.com/t/autosize/263594/7 "2008-06-17T16:37:26Z")

</div>

```auto
info.autoSize = true;
info.wordWrap = true; 
textbox._visible = false;

textbox._width = info._width;

```

Didn’t work, do I need to write a function?

---

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [June 17, 2008, 4:45pm UTC](https://forum.kirupa.com/t/autosize/263594/8 "2008-06-17T16:45:30Z")

</div>

works fine for me

---

<div class="post-metadata">

**Author:** ![vxd](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vxd](https://forum.kirupa.com/u/vxd)\
**Post date:** [June 18, 2008, 2:25am UTC](https://forum.kirupa.com/t/autosize/263594/9 "2008-06-18T02:25:11Z")

</div>

I got it working, didn’t relise it was working because I had made the textbg the same size as the text box.  
Thanks mrwicked

I have problem though;  
Is there a way to make the text box background size perfectly to the size of the width no matter how long or short the text box is?

I understand that I need to set the width of the text box to determine the length before it wraps but when I do this the text box background will be that length no matter how short the information in the text box is.

If you look at the attachments you see what I mean.  
text01.fla is fine if I have a lot of text but text02.fla wouldn’t work if I only have a few characters.

thanks Again  
Vu

---

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [June 18, 2008, 5:37am UTC](https://forum.kirupa.com/t/autosize/263594/10 "2008-06-18T05:37:13Z")

</div>

well taking this line out seemed to fix it i think:

info.wordWrap = true;

---

<div class="post-metadata">

**Author:** ![vxd](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vxd](https://forum.kirupa.com/u/vxd)\
**Post date:** [June 18, 2008, 9:36am UTC](https://forum.kirupa.com/t/autosize/263594/11 "2008-06-18T09:36:23Z")

</div>

But then the all the information is just on the one line.
