# Dynamic height rescale (based on string.length)

**URL:** <https://forum.kirupa.com/t/dynamic-height-rescale-based-on-string-length/267940>\
**Category:** Uncategorized\
**Created:** [August 7, 2008, 1:59pm UTC](https://forum.kirupa.com/t/dynamic-height-rescale-based-on-string-length/267940 "2008-08-07T13:59:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixeldude](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pixeldude](https://forum.kirupa.com/u/pixeldude)\
**Post date:** [August 7, 2008, 1:59pm UTC](https://forum.kirupa.com/t/dynamic-height-rescale-based-on-string-length/267940/1 "2008-08-07T13:59:11Z")

</div>

Hi there…

Okay what I after is how to detect the length of the string populated from array…then auto rescale the height of the title\_mc as shown in my AS as well as the dynamic created textfield …so the textfield will display long string + “newline” for long string…(autowrapper)…

eg:

// for short text keep remain the standard size of height  
mc.title\_mc.tf.text = “short text”;

//for long string it will expandable the title\_mc.height as well…dynamically  
mc.title\_mc.tf.text = “standard width title\_mc”+newline;  
//by the time string move to newline the title\_mc.height also will increase

so how to determines the long string and auto rescale the title\_mc.height

here’s the code currently I’m using…

```auto

     [LEFT][COLOR=#0000ff]stop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];

[COLOR=#000000] **var** [/COLOR] sometesttext:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Array[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"super super super longggggggg textttttttt iiiiiiiii guesssssssssss"[/COLOR],[COLOR=#ff0000]"intermediate text"[/COLOR],[COLOR=#ff0000]"short text"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000] **var** [/COLOR] len:[COLOR=#0000ff]Number[/COLOR] = sometesttext.[COLOR=#0000ff]length[/COLOR];

[COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"mc"[/COLOR],[COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]getNextHighestDepth[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];

[COLOR=#0000ff]for[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000] **var** [/COLOR] i=[COLOR=#000080]0[/COLOR];i<len;i++[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
    [COLOR=#000000] **var** [/COLOR] mc = mc.[COLOR=#0000ff]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"bubbles"[/COLOR],[COLOR=#ff0000]"bubbles"[/COLOR]+i,mc.[COLOR=#0000ff]getNextHighestDepth[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
    mc.[COLOR=#0000ff]_y[/COLOR] = [COLOR=#000080]50[/COLOR];
    mc.[COLOR=#0000ff]_x[/COLOR] = [COLOR=#000080]20[/COLOR]+mc.[COLOR=#0000ff]_width[/COLOR]*i;
    mc.[COLOR=#000080]ivar[/COLOR] = i;
    mc.[COLOR=#000080]title_mc[/COLOR].[COLOR=#0000ff]createTextField[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"tf"[/COLOR],[COLOR=#000080]100[/COLOR],mc.[COLOR=#000080]title_mc[/COLOR].[COLOR=#0000ff]_x[/COLOR],mc.[COLOR=#000080]title_mc[/COLOR].[COLOR=#0000ff]_y[/COLOR],mc.[COLOR=#000080]title_mc[/COLOR].[COLOR=#0000ff]_width[/COLOR],mc.[COLOR=#000080]title_mc[/COLOR].[COLOR=#0000ff]_height[/COLOR][COLOR=#000000])[/COLOR];
    mc.[COLOR=#000080]title_mc[/COLOR].[COLOR=#0000ff]wordWrap[/COLOR] = [COLOR=#000000] **true** [/COLOR];
    mc.[COLOR=#000080]title_mc[/COLOR].[COLOR=#0000ff]multiline[/COLOR] = [COLOR=#000000] **true** [/COLOR];
////////////////////////////////////////////
    mc.[COLOR=#000080]title_mc[/COLOR].[COLOR=#000080]tf[/COLOR].[COLOR=#0000ff]text[/COLOR] = sometesttext[COLOR=#000000][[/COLOR]mc.[COLOR=#000080]ivar[/COLOR][COLOR=#000000]][/COLOR];

    // ******** this portion how to determines in order to display 
short text and long text..

////////////////////////////////////////////    
    [COLOR=#808080]*//setting txtfield format *[/COLOR]
    myformat = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]TextFormat[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    myformat.[COLOR=#0000ff]color[/COLOR] = 0xffffff;

    mc.[COLOR=#000080]title_mc[/COLOR].[COLOR=#000080]tf[/COLOR].[COLOR=#0000ff]setTextFormat[/COLOR][COLOR=#000000]([/COLOR]myformat[COLOR=#000000])[/COLOR];

[COLOR=#000000]}[/COLOR]
[/LEFT]
 

```

thanks in advanced
