Sorry i ask for the 2nd time but i can’t find a system to make entering different words give each their own result . I tried systems like this:
bluebutton.onRelease = function() {
if (wordbox.text == “cow”) {
// if the user typed cow
results.text = “the cow goes moo”;
// put moo in the lower box
bluebutton.onRelease = function() {
if (wordbox.text == “dog”) {
// if the user typed dog
results.text = “the dog eats a bone”;
// put bone in the lower box
} else {
results.text = “enter cow or dog for this to work”;
}
};
// just make sure you close your braces.
// Notice as well that we use == to mean “if the thing on the left is the same as the thing on the right”.
// We use the equal sign = to say… “the value of the thing on the left is the thing on the right”. That is why results.text=“goes moo”,
// because we assign that value to results.text.
//
bluebutton.onRelease = function() {
if (wordbox.text == "cow") {
// if the user typed cow
results.text = "the cow goes moo";
// put moo in the lower box
} else if (wordbox.text == "dog") {
// if the user typed dog
results.text = "the dog eats a bone";
// put bone in the lower box
} else {
results.text = "enter cow or dog for this to work";
}
};
yours,
h88
**PS you can use the [*PHP]
(w/o the *) tags to add syntax highlighting and formatting to your code.**
for thouroughness sake, you could also use the switch command
bluebutton.onRelease=funtion(){
switch(wordbox.text){ // same as "if wordbox.text == "
case cow: //always end in colon
results.text="this is for the cow";
break; //this says, now that you have your answer, stop checking.
case chicken:
results.text="cluck, cluck, cluck";
break;
case turkey:
results.text="days are numbered in November";
break;
I think this method is easier to understand and use.