This content has been marked as final. Show 11 replies
you can use the restrict property of textfields to restrict the characters allowed and you can use the onChanged property of textfields to detect when a user changes the text property of your textfield.
Thanks for your reply.
I tried restrict and it does part of what I want. My only problem with it is that I want the dash (-) character in the restrict string but it has a special meaning for 0-9 or a-z and so I can't make restrict recognize it as a character that I want to allow. Does that make sense? Do you know how to do that?
use the escape character (backslash) to designate a dash.
Thanks again for the reply. I tried that and it didn't work but I tried again and I still can't get it to work.
this.restrict = "0-9 +xX*=rR()//-";
I want both the backslash and the dash to work. The backslash works but not the dash.
that code wouldn't allow a backslash (\). it allows a forward slash (/) and the last two characters do nothing.
backslash = \
Oops, my bad. I've been trying so many different things.
This is the one you think should work:
this.restrict = "0-9 /+xX*=rR()\-";
But it doesn't, sadly.
you need to escape the escape character. use:
this.restrict = "0-9 /+xX*=rR()\\-";
You can use textFeild.onChanged functions to restrict your characters at the time of entering the values....
Thank you! That worked.
Could you answer the other question? When I create a text input field with the text tool, the actionscript editor windows says "current selection cannot have actions applied to it". I have to use a text input component. Is there really no way to apply actions to text input fields?
The only reason I want to use the text edit field instead of the the text input component is because I can't seem to get the font attributes to apply in the component. It will only use some default which looks like ariel pnt 9 or something.
Thanks for all of your time. I really appreciate it. I posted the same question yesterday on the general question forum and nobody answered.
Thanks, I am going to experiment with that. I think it will be the answer to the other problem I am having.
that's correct, you cannot apply actions to a textfield. however, you can create a movieclip that contains a textfield and have all the functionality that you could desire (within the limitations of flash).
components are movieclips, so they can have actions applied to them. but they also carry quite a bit of extra baggage and are prone to cause problems.