views:

25

answers:

1

Hello every one,

iam very new to action script.i have one problem.
i have one input textbox.To enter 5x^2 ,key sequence used are "5" "x" "2" ie.,the characters must be formatted as it is being typed.I want to enter equations like "5x^2-4x-2".It should not allow other characters other than "x", using action script 2.0 .Please help me any one.

A: 

You can restrict an input text field to only take certain characters using TextField.restrict See the docs here

danjp
Hello, thankq for ur reply.iam not getting character comparsion.I embeded Characters "all numbers,x,+,-" in the properties dialog for my_txt(my text field instance).iam comparing the last char with x.if equal the next character should be a number if((input.substring((input.length)-1, input.length)=="x") { trace("ok"); } }
Kalavathi
It isn't clear to me exactly what you want. It looks like you are trying to input quadratic equations, but without knowing the value of (x) you can't apply Math functions to it. What I think you need to look into is String.indexof('x') which will return the position in the string of this character. If you do this on all the non-numerical characters then you should be able to determine the structure of the inputted string.
danjp