i just needed to make a little modification to avoid the last word in
the last line of left column appearing in first line of right column
when there was a car return in it
the only problem i have found so far is a slow performance with long
strings (as you can expect with string operations)
thanks for your help!
function setDesc(descText) {
var overflow:Boolean = false;
for (var i=0; i<descText.length; i++) {
desc_left.text = descText.substring(0, i);
if (desc_left.maxscroll>1) {
overflow = true;
break;
}
}
if (!overflow) {
desc_left.text = descText;
} else {
if (desc_left.text.charCodeAt(desc_left.text.length-2) == 13) {
breakPt = desc_left.text.length-2;
} else {
breakPt = descText.lastIndexOf(" ", i);
}
desc_left.text = descText.substring(0, breakPt);
desc_right.text = descText.substring(breakPt+1);
}
}
[quoted text, click to view] kglad wrote:
> if your textfields have instance names tf1 and tf2 (and are non-html), and your
> file returning your text is test.txt and it's returning the variable yourvar,
> you can use:
>
>
>
> lv = new LoadVars();
> lv.onLoad = function() {
> for (var i = 0; i<this.yourvar.length; i++) {
> tf1.text = this.yourvar.substring(0, i);
> if (tf1.maxscroll>1) {
> break;
> }
> }
> breakPt = this.yourvar.lastIndexOf(" ", i);
> tf1.text = this.yourvar.substring(0, breakPt);
> tf2.text = this.yourvar.substring(breakPt+1);
> };
> lv.load("test.txt");