hello.
i have an input typetextbox on my stage called stakebox.i m using it in my project called matrix.
i want negetive value to be enter by user. but i can’t do that ma own… so plz help me…
length of that textbox is 4. i have given some code to that… i mannaged to enter dot once. but i want minus “-” to enter only one time… any in my text box “-” and “.” are covery the length of my text box. i can only write -0.0, but i want - or . to be saperate for the length…
i want the value should be of these format…
let zero be any value…
-0.0;
-.0;
0.0;
…
my code are :
_root._lastLen = _root.stakeBox.text.length;
_root.stakeBox.onChanged = function()
{
var tmp = this.text;
var len = tmp.length; // needed for later use
var carIn = Selection.getCaretIndex(); // for cursor consistency purposes
if(len-_root._lastLen>1) // if paste method is used, and the pasted length is more than 1
{
var firstDot = tmp.indexOf(".");
tmp = tmp.split(".").join("");
this.text = tmp.substring(0, firstDot) + “.” + tmp.substring(firstDot);
lenDiff = len - this.text.length;
Selection.setSelection(carIn-lenDiff, carIn-lenDiff);
}
if(tmp.indexOf(".")!=tmp.lastIndexOf(".")) // normal input, or if pasted length is just 1
{
this.text = tmp.substring(0, carIn-1) + tmp.substring(carIn, tmp.length);
Selection.setSelection(carIn-1, carIn-1);
}
_root._lastLen = this.text.length;
}