;

PDA

Click to See Complete Forum and Search --> : Can someone please set me straight on dynamic textbox?


jarnold
08-18-2008, 12:51 AM
Hi,
Sorry this is so long!
I tutor in english/maths and use specialized software (written in DOS) which won't work in Vista. I want to see if KM/Flash can be used to replicate the work. Trouble is I don't know actionscript! I hope someone can give me pointers a bit at a time. Problem: I want to use a textbox to go to a frame when the correct word is entered and the "enter" key is pushed. I made a textbox labelled "answer" in frame 4.
var a is there to show the correct score on frame 5, frame 6 is if incorrect and goes back to frame1

var a = 0;
var txt1 = "";
on (release, keyPress "enter"){if (txt1.txt = "cat"){
gotoAndStop (5); } else {
gotoAndStop (6); }
}

When I play "in browser" it doesn't go to frame5 or 6 after I enter cat and hit the enter key.
If anyone can help that would be greatly appreciated.
ja :eek:

necromanthus
08-18-2008, 08:44 AM
Presuming the input field (dynamic text) is txt1 and its variable name is txt1var, set this script in the 4th keyframe timeline:

txt1var = "";
this.onEnterFrame = function() {
if (Key.isDown(Key.ENTER)) {
if (this._currentframe == 4) {
if(txt1var == "cat"){
gotoAndStop(5);
}else if(txt1var != ""){
gotoAndStop(6);
}
}
}
}
stop();


important note: be sure all your keyframes have NO tweens!
:mrpimp:

ghol
08-18-2008, 09:06 AM
I have made one try it out, I am new to KoolMoves as well but not flash.

ghol
08-19-2008, 01:37 AM
Basically I have two dynamic text box in single frame and I want to force user to type in 1st text box, if not warn/alert them in 2nd text box. if the correct text "ghol" typed go and next frame, else alert them with some new message in the 2nd text box again.


see the demo here http://img515.imageshack.us/img515/4867/variablenm4.swf and in 1st text box type " ghol " to see the result.

Please help me to accomplish this and thank you.

I did this in 3 frames as you see in my first post above, but I do not know how to do it in single frame.

jarnold
08-19-2008, 02:01 AM
Presuming the input field (dynamic text) is txt1 and its variable name is txt1var, set this script in the 4th keyframe timeline:

txt1var = "";
this.onEnterFrame = function() {
if (Key.isDown(Key.ENTER)) {
if (this._currentframe == 4) {
if(txt1var == "cat"){
gotoAndStop(5);
}else if(txt1var != ""){
gotoAndStop(6);
}
}
}
}
stop();


important note: be sure all your keyframes have NO tweens!
:mrpimp:

Thank you for replying. I tried adding the code but when I type in the word cat nothing happens when I hit the enter key. I can put it in a directory if you would like to see what I'm doing wrong. ghol has kindly provided a solution but I don't want a button - the enter key will be used all the time.
thanks for your time
ja

jarnold
08-19-2008, 02:04 AM
I have made one try it out, I am new to KoolMoves as well but not flash.
Thanks for your effort, ghol. I need the enter key as the way to send to the next frame. This is going to be repeated often so clicking on a button will become boring for the kids to do.
Thanks
ja

necromanthus
08-19-2008, 03:25 AM
Thank you for replying. I tried adding the code but when I type in the word cat nothing happens when I hit the enter key.

OMG ... see the attached file.

jarnold
08-19-2008, 08:58 PM
Thanks necromanthus for the file. I had each frame lasting .5 secs to hear the sound of the word before typing it in. Will have to repeat the frame instead.
ja

blanius
08-19-2008, 09:31 PM
you can have tweens, it just requires that you do a little more coding.

or you could have the sound as an seperate object that you play, then it's in it's own timeline.

jarnold
08-19-2008, 10:58 PM
Hi, "a little more coding" sounds like a lot for me :yikes: I would like to learn how to do it. The preference is to have the sound played automatically and then have the rest follow. Is there a tutorial I can follow?
thanks,
ja

necromanthus
08-20-2008, 03:52 AM
Thanks necromanthus for the file. I had each frame lasting .5 secs to hear the sound of the word before typing it in. Will have to repeat the frame instead.

You don't need 0.5 seconds per frame to hear a sound.
You can achieve that using a little piece of script.
Anyway, for beginners (if they use tweens) I highly recommend "frame labels".
Something like:

if(txt1var == "cat"){
gotoAndStop("ok_frame");
}else if(txt1var != ""){
gotoAndStop("error_frame");
}


cheers

jarnold
08-22-2008, 02:22 AM
Thnks for your help - will keep working on it!

jarnold
08-22-2008, 08:07 AM
Thnks for your help - will keep working on it!
Can't spell what hope have I got of typing in the right code!!! Thanks again guys. I have used a button for the sound but will still need tweens to see the word before the textbox to enter that word.
ja

jarnold
08-31-2008, 09:19 AM
Hope I can try your patience a little more! I've made a small swf file for the "cat" sound, made a menu and a button to call the movie ( is it a movieclip (MC2) when embedded?) and it runs - can only make it then disappear and go back to the menu with a button. Tried loadMovie(MC2,1) playMovie(MC2,1) unloadMovie(MC2,1)
nextFrame() in the same frame as MC2 but it skips movie.
Any help appreciated
ja

thesween
08-31-2008, 11:14 AM
Have you tried creating a mc and using something like the following in the button?..

on(release) {
mc2.loadMovie("folder1/file1.swf");
}

upload your swf if this is not what your trying to do so we can have a look at it.

Cheers
Steve

jarnold
09-01-2008, 12:47 AM
Thanks Steve,
I can load and play the imported movie but unless I use a button I can't remove it and go back to the menu.
ja

jarnold
09-07-2008, 08:18 AM
Thank you for the help so far. Why does this code only work with no tweens? Can you also show me where I'm going wrong with this, please.
If student is wrong - var bad_word = "moo" I then have a textbox endtestvar and use

endtestvar = Array("these words" + bad_word + bad_word1 + bad_word3 + bad_word4 + bad_word5 +bad_word6 + bad_word7 + bad_word8 + bad_word9);
_level0endtestvar=endtestvar

I get "undefined" for every word the student gets right. Also would like the result spread out over a couple lines. Do I use ',' ???
ja

blanius
09-07-2008, 03:44 PM
yes comma to separate elements in an Array.

jarnold
09-16-2008, 08:28 AM
Hi can you please look at this and let me know why this doesn't work. Should the code for the new array be in the text box actionscript or in the "correct" page and "wrong" page actionscript?
thanks,
ja