# Length of text

**URL:** https://forum.kirupa.com/t/length-of-text/24597
**Category:** Uncategorized
**Created:** [July 2, 2003, 3:53pm UTC](https://forum.kirupa.com/t/length-of-text/24597 "2003-07-02T15:53:56Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![pspecial](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@pspecial](https://forum.kirupa.com/u/pspecial)
#### Post date: [July 2, 2003, 3:53pm UTC](https://forum.kirupa.com/t/length-of-text/24597/1 "2003-07-02T15:53:56Z")

</div>

Does anyone know how to determine the length of whats in a dynamic text field once an external .txt is loaded?

What I’m trying to do is find the value so that if it exceeds a certain number of characters I can set a scroll bar to \_visible = true;

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 2, 2003, 4:11pm UTC](https://forum.kirupa.com/t/length-of-text/24597/2 "2003-07-02T16:11:15Z")

</div>

Well, TextField.length is the function, but why don’t you just use MX’s scrollBar components, and set them to auto? It’d be easier. Oh well, I guess you probably thought of that.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 2, 2003, 6:02pm UTC](https://forum.kirupa.com/t/length-of-text/24597/3 "2003-07-02T18:02:56Z")

</div>

No I didnt think of that. I am using a scrollbar component but how do you set it to auto?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 2, 2003, 6:24pm UTC](https://forum.kirupa.com/t/length-of-text/24597/4 "2003-07-02T18:24:19Z")

</div>

Ah, I see the problem. Drat. The bastards at macromedia only added an auto/true/false state to the “scrollPane” component, which really doesn’t work with dynamic text (or at least I haven’t yet been able to make it work). So I guess you’ll have to do it your way using the TextField.length function.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 2, 2003, 7:01pm UTC](https://forum.kirupa.com/t/length-of-text/24597/5 "2003-07-02T19:01:59Z")

</div>

Well I figured it out. Here’s the solution:

\_root.bar.\_visible = false;  
loadText = new loadVars();  
loadText.load(“text1.txt”);  
loadText.onLoad = function(success) {  
if (success) {  
newsBox.html = true;  
newsBox.htmlText = this.myNews;  
textLength = this.myNews.length  
if (textLength \> 180) {  
\_root.bar.\_visible = true;  
}  
}  
}

The if statement condition may vary depending on your text box size. Here, I set the bar to be visible if there are more than 180 characters in the .txt file.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 2, 2003, 7:37pm UTC](https://forum.kirupa.com/t/length-of-text/24597/6 "2003-07-02T19:37:12Z")

</div>

:q:

Why not just use [AS]if (textFieldInstanceName.maxScroll \> 0){  
bar.\_visible = true;  
}[/AS]

[edit]lemme test this…lol[/edit]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 2, 2003, 7:43pm UTC](https://forum.kirupa.com/t/length-of-text/24597/7 "2003-07-02T19:43:57Z")

</div>

Ok this works 🙂

[AS]if (tf.maxscroll\>1) {  
bar.\_visible = true;  
} else {  
bar.\_visible = false;  
}[/AS]

Where tf is the textfields instance name and bar is the instance name of the scrollbar.
