You can check textfield.maxscroll
On 12/20/06, Danny Kodicek <[EMAIL PROTECTED]> wrote:
> Hi all,
> I need to restrict user input to a certain number of lines in
> a textfield.
> Flash 8, AS2.
> After an extensive search something like this showed up:
>
> //txtFld is obviously the TextField, n is the max number of
> lines shrinkString = function (txtFld, n:Number):Void {
> var l = txtFld.text.length;
> for (var i = 0; i<l; i++) {
> txtFld.scroll = txtFld.maxscroll;
> if (txtFld.bottomScroll>n) {
> txtFld.text = txtFld.text.slice(0, -1);
> } else {
> break;
> }
> }
> };
> myTextField.onChanged = function() {
> shrinkString(this, 10);
> };
>
> This is close to what I need but it has a major drawback; it
> simply cuts off the text at the end. So when a user inserts a
> 'return' an entire line of text disappears.
How about something like this?
obj = new Object()
obj.maxHeight = 100
obj.currText = txtField.text
obj.onKeyDown = function () {
this.currText = txtField.text
}
obj.onChanged = function() {
if (txtField.textHeight>100) {
txtField.text = this.currText
}
}
txtField.addListener(obj)
Key.addListener(obj)
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
--
/*
Bored, sometimes.
*/
_______________________________________________
[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