Text based game input help
- Frankmank
-
Frankmank
- Member since: Jun. 11, 2006
- Offline.
-
- Forum Stats
- Member
- Level 06
- Blank Slate
I've got the input text where you type in the command you want to try, and then the dynamic text box which displays what you just typed in, the problem is it does it immediately, I'd like to have it so it displays after hitting enter and then clear the input text field, I don't use input text fields ever so i'm looking for some pointers.
- Sam
-
Sam
- Member since: Oct. 1, 2005
- Offline.
-
- Forum Stats
- Moderator
- Level 19
- Programmer
So youd enter the command into this textbox with the var "input".
On the frame have something like:
onLoad = function(){
input = ""
}
onEnterFrame = function(){
if(Key.isDown(Key.ENTER)){
if(input=="COMMAND"){
gotoAndPlay(2);
}
}
} - Frankmank
-
Frankmank
- Member since: Jun. 11, 2006
- Offline.
-
- Forum Stats
- Member
- Level 06
- Blank Slate
At 2/22/09 07:02 PM, Saza wrote: So youd enter the command into this textbox with the var "input".
On the frame have something like:
onLoad = function(){
input = ""
}
onEnterFrame = function(){
if(Key.isDown(Key.ENTER)){
if(input=="COMMAND"){
gotoAndPlay(2);
}
}
}
It does exactly as it did before, as I type in the input text it instantly is shown in the dynamic text box as I type it, I want it so the dynamic text box is empty until I hit enter in the input, which is then sent to the dynamic text box
- Frankmank
-
Frankmank
- Member since: Jun. 11, 2006
- Offline.
-
- Forum Stats
- Member
- Level 06
- Blank Slate
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
Change the input textbox var to inTxt and the dynamic textbox var to dynTxt
Add this to the main timeline
kl=new Object();
kl.onKeyDown=function(){
if(Key.getCode()==13){ //ENTER
dynTxt=inTxt;
}
}
Key.addListener(kl); - Frankmank
-
Frankmank
- Member since: Jun. 11, 2006
- Offline.
-
- Forum Stats
- Member
- Level 06
- Blank Slate
At 2/23/09 09:58 AM, Denvish wrote: Change the input textbox var to inTxt and the dynamic textbox var to dynTxt
Add this to the main timeline
kl=new Object();
kl.onKeyDown=function(){
if(Key.getCode()==13){ //ENTER
dynTxt=inTxt;
}
}
Key.addListener(kl);
Thanks, it works perfectly except for clearing the input box but I fixed that easily enough.
Now I wondering which is the most efficient way of checking the answers put into the input box arrays or what? all the coding I do is checking variables against each other and that might get too bulky for this game.
- Frankmank
-
Frankmank
- Member since: Jun. 11, 2006
- Offline.
-
- Forum Stats
- Member
- Level 06
- Blank Slate
Also I'm wondering how to check the commands inputted, because as I have it set up now it doesn't seem to be working.
onEnterFrame=function(){
if (dynTxt == "play"){
nextFrame();
}}; - Frankmank
-
Frankmank
- Member since: Jun. 11, 2006
- Offline.
-
- Forum Stats
- Member
- Level 06
- Blank Slate
Come on, this can't be a difficult question.
- BillysProgrammer
-
BillysProgrammer
- Member since: Sep. 17, 2008
- Offline.
-
- Forum Stats
- Member
- Level 16
- Gamer
if not, then you do it :P
var dynText = inputtextinstancename.text;
onEnterFrame = function() {
if(dynText == "play") {
//bah
}
} - Frankmank
-
Frankmank
- Member since: Jun. 11, 2006
- Offline.
-
- Forum Stats
- Member
- Level 06
- Blank Slate
At 2/24/09 12:42 AM, BillysProgrammer wrote: if not, then you do it :P
var dynText = inputtextinstancename.text;
onEnterFrame = function() {
if(dynText == "play") {
//bah
}
}
Ouch, well as I said I don't have any experience with text boxes besides displaying variables.
Anyhoo, that doesn't seem to work,
onEnterFrame=function(){
if (dynTxt("play")){
trace("working")
nextFrame();
}} - BillysProgrammer
-
BillysProgrammer
- Member since: Sep. 17, 2008
- Offline.
-
- Forum Stats
- Member
- Level 16
- Gamer
Now you have it as a function. When you do blah() its a function or your working with OOP (object oriented program) and so far its a no..
Learn to use google man...
"Checking input text in flash actionscript 2.0"




