;

PDA

Click to See Complete Forum and Search --> : Conversion Calculator


tmoore935
11-14-2006, 08:02 PM
http://www.diversioncentral.com/calculator/betaconversions.html

I was thinking of putting this on the koolexchange. If you see a problem or bug, please let me know.

Chris_Seahorn
11-14-2006, 09:09 PM
Cool.

Only suggestion I have is to restrict the input fields to numbers only. Great job Tim :thumbsup: :thumbsup:

tmoore935
11-14-2006, 09:30 PM
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"?

Chris_Seahorn
11-14-2006, 09:59 PM
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 :)

tmoore935
11-14-2006, 10:16 PM
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.

Chris_Seahorn
11-14-2006, 10:34 PM
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:

Stoke Laurie
11-15-2006, 12:39 PM
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.

blanius
11-16-2006, 12:34 AM
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

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
}

}


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.

And which ever box you edit the other shows the calulated value

Chris_Seahorn
11-16-2006, 12:46 AM
Yeah...good call. Once this baby is ready I want one :)

tmoore935
11-16-2006, 12:51 AM
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";

Chris_Seahorn
11-16-2006, 01:14 AM
That is the unicode escape equivilent of "." (period).

You could also use:

txt1_txt.restrict = "0-9 .";

or

txt1_txt.restrict = "0-9, .";

etc

tmoore935
11-16-2006, 01:33 AM
Ok. I guess the forwardslash made it look like an equation or something.
Thanks all.

tmoore935
11-17-2006, 08:11 PM
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;
}

}

blanius
11-17-2006, 10:13 PM
002D is ASCII for -

Try
txt1.restrict = "0-9\u002E\u002d";

tmoore935
11-17-2006, 10:17 PM
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.
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:

blanius
11-17-2006, 10:25 PM
Ok Tom You made me go look at the Flash 8 docs... LOL

txt1.restrict = " 0-9\u002E\\-";

blanius
11-17-2006, 10:27 PM
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";

tmoore935
11-17-2006, 10:37 PM
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?

blanius
11-17-2006, 11:01 PM
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.

Like this avatar better. (yes that's me)

tmoore935
11-17-2006, 11:37 PM
Like this avatar better. (yes that's me)

Yea, but the kids not so ugly.
Whoops..Thats why I don't post pics of myself...nevermind
Really though. Thanks for the help :cool:

Stoke Laurie
11-18-2006, 06:00 AM
I prefer the cowboy one Brett!!! - My avatar says it about all about me, the old joker!