I have a fill-in-the-gaps exercise and I have added a hint button which checks to see which part of the word a student has entered is correct and then adds the next (correct) letter to the end of the string. My problem is that the cursor stays just in front of the added letter instead of going to the end of the string. I've tried selecting the letter that has just been added and for a second the last letter is highlighted but then the cursor goes back to its original place. Here's the code I'm using:

function showLetter() {
      //get the text the student has entered
      currentWord = eval("gap"+currentGap).gap_txt.text;
      currentLength = currentWord.length;
      newText = "";
      correctText = gWords[currentGap];
      lastLetter = 0;
      //compare it one letter at a time to the correct answer
      for (j=0; j<currentWord.length; j++) {
              if (currentWord.charAt(j) == correctText.charAt(j)) {
                      newText += correctText.charAt(j);
                      lastLetter = j;
              } else {
                      break;
              }
      }
      currentLength = newText.length;
//show the correct portion of the text plus the next (correct) letter eval("gap"+currentGap).gap_txt.text = gWords[currentGap].substr(0, currentLength+1);
      eval("gap"+currentGap).gap_txt.setTextFormat(numFormat);
      //select the last letter - this does not move the cursor
      Selection.setSelection(currentLength,currentLength+1);

}

I would appreciate any ideas on how this could be done.

Thanks,

Birgit

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to