A Flash Developer Resource Site

Results 1 to 19 of 19

Thread: Can someone please set me straight on dynamic textbox?

  1. #1
    Member
    Join Date
    Aug 2008
    Posts
    78

    Can someone please set me straight on dynamic textbox?

    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

  2. #2
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Presuming the input field (dynamic text) is txt1 and its variable name is txt1var, set this script in the 4th keyframe timeline:
    Code:
    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!

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Posts
    25
    I have made one try it out, I am new to KoolMoves as well but not flash.
    Attached Files Attached Files

  4. #4
    Junior Member
    Join Date
    Jul 2008
    Posts
    25

    variable

    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.
    Attached Files Attached Files
    Last edited by ghol; 08-19-2008 at 12:43 AM.

  5. #5
    Member
    Join Date
    Aug 2008
    Posts
    78

    thanks for replying

    Quote Originally Posted by necromanthus
    Presuming the input field (dynamic text) is txt1 and its variable name is txt1var, set this script in the 4th keyframe timeline:
    Code:
    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!
    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

  6. #6
    Member
    Join Date
    Aug 2008
    Posts
    78

    reply

    Quote Originally Posted by ghol
    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

  7. #7
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Quote Originally Posted by jarnold
    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.
    Attached Files Attached Files

  8. #8
    Member
    Join Date
    Aug 2008
    Posts
    78

    sample file

    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

  9. #9
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    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.

  10. #10
    Member
    Join Date
    Aug 2008
    Posts
    78

    a liitle more coding

    Hi, "a little more coding" sounds like a lot for me 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

  11. #11
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Quote Originally Posted by jarnold
    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:
    Code:
    if(txt1var == "cat"){
    	gotoAndStop("ok_frame");
    }else if(txt1var != ""){
    	gotoAndStop("error_frame");
    }
    cheers

  12. #12
    Member
    Join Date
    Aug 2008
    Posts
    78

    textbox

    Thnks for your help - will keep working on it!

  13. #13
    Member
    Join Date
    Aug 2008
    Posts
    78
    Quote Originally Posted by jarnold
    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

  14. #14
    Member
    Join Date
    Aug 2008
    Posts
    78
    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

  15. #15
    theSWEEN thesween's Avatar
    Join Date
    Nov 2005
    Location
    Hertfordshire, England
    Posts
    305
    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

  16. #16
    Member
    Join Date
    Aug 2008
    Posts
    78

    unload movie

    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

  17. #17
    Member
    Join Date
    Aug 2008
    Posts
    78

    some more questions on the textbox

    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

  18. #18
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    yes comma to separate elements in an Array.

  19. #19
    Member
    Join Date
    Aug 2008
    Posts
    78

    more on the textbox

    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
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center