> How can you efficiently fill a textfield to the point in which you know it
> is completely full?
Here's a revised version using a word array. But as I said, including
formatting would be more difficult and significantly slower. I tend to agree
with Meinte that in this case you're better off using scrolling (although
the function below may be of interest in any case)
function fillField(fld:TextField, txt:Array, curr:String) {
if (curr == undefined) {
curr = "";
}
var len:Number = txt.length;
if (len == 0) {
} else if (len == 1) {
fld.text = curr + txt[0];
if (fld.textHeight > fld._height) {
fld.text = curr;
}
} else {
var half:Array = txt.slice(0, len / 2);
fld.text = curr + half.join(" ");
if (fld.textHeight > fld._height) {
fillField(fld, half, curr);
} else {
fillField(fld, txt.slice(len / 2), fld.text + " ");
}
}
}
I tested it with
fillField(test, src.text.split(" "));
Danny
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com