Yes that's right, that wouldn't work in that case. Then one solution would be to save the text property when you know it's below the limit (for example in the TextInput event), then in the CHANGE event, check the text height again. If it's above the limit, restore the previous text property. You might also want to save and restore the caret position as well (see selectionStartIndex and selectionEndIndex)
-- Laurent Cozic Flash, Flex and Web Application development http://pogopixels.com ----- Original Message ---- From: tchredeemed <[EMAIL PROTECTED]> To: [email protected] Sent: Tuesday, August 5, 2008 3:07:37 PM Subject: [flexcoders] Re: TextArea - Limit the amount of text no no, thats not the issue the issue is this a b c is a certain textHeight, whether the cursor is on the a or the c, so if they hit that textHeight, then no matter whree they put the cursor, the textHeight is at the limit, so i prevent the default. if I delete the c, the textHeight is no longer at its limit, so I can edit anywhere I want. make sense? --- In [EMAIL PROTECTED] ups.com, Laurent Cozic <pogopixels@ ...> wrote: > > I haven't checked but I guess that the TextEvent.text property is empty if you are deleting text. If that's the case, then don't cancel the event. > > -- > Laurent Cozic > > Flash, Flex and Web Application development > http://pogopixels. com > > > > ----- Original Message ---- > From: tchredeemed <[EMAIL PROTECTED] > > To: [EMAIL PROTECTED] ups.com > Sent: Tuesday, August 5, 2008 2:57:32 PM > Subject: [flexcoders] Re: TextArea - Limit the amount of text > > > Ok, that is definitely a step in the right direction. > > 1 problem: > > After they hit that max, it doesn't allow them to go back and change > old text that they already edited, because the textHeight has been > reached, so it prevents them from changing (essentially setting > enabled=false) . > > Any ideas? > > --- In [EMAIL PROTECTED] ups.com, Laurent Cozic <pogopixels@ ...> wrote: > > > > You could do it by listening to the textInput event. When it's > triggered, check if the text height is above a certain limit (for > example the TextArea height - font height): if it is, cancel the event. > > > > The code below should work: > > > > > > textArea.addEventLi stener(TextEvent .TEXT_INPUT, textArea_textInput) ; > > > > protected function textArea_textInput( event:TextEvent) { > > if (textArea.textHeigh t > textArea.height - > textArea.getStyle( "fontSize" )) { > > event.preventDefaul t(); > > } > > } > > > > > > > > -- > > Laurent Cozic > > > > Flash, Flex and Web Application development > > http://pogopixels. com > > > > > > > > ----- Original Message ---- > > From: tchredeemed <apthorp@ > > > To: [EMAIL PROTECTED] ups.com > > Sent: Tuesday, August 5, 2008 2:27:55 PM > > Subject: [flexcoders] TextArea - Limit the amount of text > > > > > > I am creating a web-to-print Greeting Card Editor. > > > > I need to limit the amount of text someone can put in the editable > > field (obviously cannot print more than the printable area). > > > > I cant just do maxChars, because it can fit variable amount depending > > on the amount of i's and w's used, etc! > > > > any help is appreciated. > > >

