| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Random Frame when answer is correct
As topic says i want my game to go to a random frame when i am inserting the right answer in the input text.
After a couple of hours searching for the correct Action script i came up with this: Code:
on (release, keyPress "<Enter>") {
gotoAndStop(random(6));
}
But as you see it doesn't matter if it is the correct answer or not it just goes to a random frame when i am pressing the button. I tried adding this: Code:
if (answer = "a"); (My input text Var is answer) Without any success, and i am now sitting here like a big Question mark, i would really appreciate it if you could help me with this one. Thanks //Banjo Last edited by Banjo : May 4th, 2008 at 03:56 AM. |
|
#2
|
|||
|
|||
|
Firstly. Does your random code work?? Cause I've been looking for that for a while.
But try this, or have you already? Code:
on (release, keyPress "<Enter>") {
if (_root.answer = "a");
gotoAndStop(random(6));
trace ("Your answer is correct.");
} else if (_root.answer != "a") {
trace ("Your answer is incorrect.");
}
}
__________________
Ask me for help in the following areas: Flash - Should be able to help HTML/Dreamweaver/Web Design - Should be able to help. CSS - Can help in some areas Also working on: JavaScript PHP C++ DHTML |
|
#3
|
|||
|
|||
|
Code:
on (release, keyPress "<Enter>") {
gotoAndStop(random(6));
}
this one works it will take you a random frame 1-6, but as i said it didn't work when i tried binding it with my input text. If that is what you mean But thanks i will try that one as soon as i am home Thanks /Banjo |
|
#4
|
|||
|
|||
|
Code:
**Error** Scene=Scene 1, layer=Layer 1, frame=6:Line 4: 'else' encountered without matching 'if'
} else if (_root.answer != "a") {
Total ActionScript Errors: 1 Reported Errors: 1
:\\ Code:
on (release, keyPress "<Enter>") {
if (_root.answer = "a");
gotoAndStop(random(6));
}
Tried this one and it worked except that if you press the button with no text in the input box it just writes down an A and goes to another frame. I will try to figure out a solution Thanks again //banjo |
|
#5
|
||||
|
||||
|
I might sound dumb, but where is this code going in?
|
|
#6
|
|||
|
|||
|
Sorry... I didn't test that. It doesn't like the if in the else if () {. Just change it to else () {
Sorry again. |
![]() |
| Viewing: Tutorialized Forums > 2D Graphics > Flash > Random Frame when answer is correct |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|