http://www.diversioncentral.com/calc...nversions.html
I was thinking of putting this on the koolexchange. If you see a problem or bug, please let me know.
Printable View
http://www.diversioncentral.com/calc...nversions.html
I was thinking of putting this on the koolexchange. If you see a problem or bug, please let me know.
Cool.
Only suggestion I have is to restrict the input fields to numbers only. Great job Tim :thumbsup: :thumbsup:
I was looking for something consumer oriented. What problem did you find? Why do you say "numbers only"?Quote:
Originally Posted by Chris_Seahorn
If they enter a letter the conversion will return "NaN" (not a number). It's not a big deal and doesn't affect function so forget I mentioned :)
See what you mean Chris. This is why I posted. Looking for all the mistakes. I will repost when done. This application whould be worthless without your help.
No way man. That baby is all you. Really useful too. I would definitely submit that if I were you :thumbsup: :thumbsup:Quote:
Originally Posted by tmoore935
Great idea, could use something like that on my sites as a "stcky resource" or logo it up as a download as a projector with the site name on. Great thinking, please put in the exchange.
Tmoore You might either not allow the result field to be edited, OR consider allowing one to do both like Gallon to Liter and liter to gallon and use the event onChanged to know wich direction to do the calculation.
Here's a code snippet to consider
Put two text boxes on the stage txt1 and txt2 and try this. This way you can only enter 0-9 and the '.' and it only calculates if the textbox is not NULL to avoid the NaN.Code:txt1.restrict = "0-9\u002E";
txt2.restrict = "0-9\u002E";
txt1.onChanged=function(){
if (txt1.text!=""){
txt2.text=txt1.text*3.7853
}
}
txt2.onChanged=function(){
if(txt2.text!=""){
txt1.text=txt2.text*.2642
}
}
And which ever box you edit the other shows the calulated value
Yeah...good call. Once this baby is ready I want one :)
I could change this before I submit. It would also reduce the amount of buttons.
But I do not understand the
txt1.restrict = "0-9\u002E";
That is the unicode escape equivilent of "." (period).
You could also use:
txt1_txt.restrict = "0-9 .";
or
txt1_txt.restrict = "0-9, .";
etc
Ok. I guess the forwardslash made it look like an equation or something.
Thanks all.
Hello, I was able to get everything to work as Blanius suggested but I have a problem with temps. This is because the answer is sometimes negative and I cannot get any display unless an answer is positive.
And what is the unicode for a math minus sign? I went online to look and I found 2212 as a unicode, but it still does not let me enter a minus sign. The same in Flash 8.
Any ideas.
This code works in flash 8 but not koolmoves.
txt1.restrict = "0-9 - .";
txt2.restrict = "0-9 - .";
txt1.onChanged=function(){
//to get F
if (txt1.text!=""){
t = txt1.text;
b = ((5/9)*(t - 32));
txt2.text = b;
}
}
txt2.onChanged=function(){
//to get C
if(txt2.text!=""){
t = txt2.text;
b = ((9/5)*t) + 32;
txt1.text = b;
}
}
002D is ASCII for -
Try
txt1.restrict = "0-9\u002E\u002d";
I tried that already which is why I went online to unicode.org. It also does not work with Flash 8.Quote:
Originally Posted by blanius
I can always omit the txt.restrict for this one particular equation, but i cannot get the answers when they are less then zero. This has me stumped. Which means its something simple. :rolleyes:
Ok Tom You made me go look at the Flash 8 docs... LOL
txt1.restrict = " 0-9\u002E\\-";
Quote:
restrict (TextField.restrict property)
public restrict : String
Indicates the set of characters that a user may enter into the text field. If the value of the restrict property is null, you can enter any character. If the value of the restrict property is an empty string, you cannot enter any character. If the value of the restrict property is a string of characters, you can enter only characters in the string into the text field. The string is scanned from left to right. A range may be specified using the dash (-). This only restricts user interaction; a script may put any text into the text field. This property does not synchronize with the Embed Font Outlines check boxes in the Property inspector.
If the string begins with ^, all characters are initially accepted and succeeding characters in the string are excluded from the set of accepted characters. If the string does not begin with ^, no characters are initially accepted and succeeding characters in the string are included in the set of accepted characters.
Availability: ActionScript 1.0; Flash Player 6
Example
The following example allows only uppercase characters, spaces, and numbers to be entered into a text field:
my_txt.restrict = "A-Z 0-9";
The following example includes all characters, but excludes lowercase letters:
my_txt.restrict = "^a-z";
You can use a backslash to enter a ^ or - verbatim. The accepted backslash sequences are \-, \^ or \\. The backslash must be an actual character in the string, so when specified in ActionScript, a double backslash must be used. For example, the following code includes only the dash (-) and caret (^):
my_txt.restrict = "\\-\\^";
The ^ may be used anywhere in the string to toggle between including characters and excluding characters. The following code includes only uppercase letters, but excludes the uppercase letter Q:
my_txt.restrict = "A-Z^Q";
You can use the \u escape sequence to construct restrict strings. The following code includes only the characters from ASCII 32 (space) to ASCII 126 (tilde).
my_txt.restrict = "\u0020-\u007E";
Ok, this works, but with + it doesnt need the forward slash. Thank you. I did read what you had posted but ignored the slashes.
Still, why does koolmoves have this problem with getting numbers less then 0 to appear?
Glad that helped, can't answer for KM, I love that movie.Quote:
Originally Posted by tmoore935
Like this avatar better. (yes that's me)
Yea, but the kids not so ugly.Quote:
Like this avatar better. (yes that's me)
Whoops..Thats why I don't post pics of myself...nevermind
Really though. Thanks for the help :cool:
I prefer the cowboy one Brett!!! - My avatar says it about all about me, the old joker!