Sorry to beat a dead horse but here's what I'm trying to do...

On the screen I have 5 words that are scrambled
The user has to type in the correct word.

Something like this...

Zelyana _ _ _ _ _ _ _  (Analyze)
Nifeed  _ _ _ _ _ _    (Define)
Fusifx  _ _ _ _ _ _    (Suffix)
Fiodmy  _ _ _ _ _ _    (Modify)
Weolv   _ _ _ _ _      (Vowel)

In sprites 15 to 19, I have a text cast member that is for the user's
answers.
In sprites 21 to 25, I have the answers (also text fields) set off the
stage.

I am trying to have one script to apply to each of the 5 text cast
members that are  for user input.

I have come up with this...

global gAnswer
global gEntryText
global gCount
global gKeyCount
global gKey
global gAnswerText
global gUserInput
global gMatch

on beginSprite me
  sprite(the currentSpriteNum).member.text = ""
  gAnswer = sprite(the currentSpriteNum + 6).member.name
  gEntryText = sprite(the currentSpriteNum).member.name
  gCount = gAnswer.length
  gKeyCount = 0
  gMatch = 0
end 

on keyDown me
  gKey = "abcdefghijklmnopqrstuvwxyz"
  case (the keyCode) of
    51: 
      delete the last char of member(gEntryText)
      if gKeyCount = 0 then
        nothing
      else
        gKeyCount = gKeyCount - 1
      end if
    117:  
      delete the last char of member(gEntryText)
      if gKeyCount = 0 then
        nothing
      else
        gKeyCount = gKeyCount - 1
      end if
    otherwise:
      if gKey contains the key then
        gKeyCount = gKeyCount + 1
        pass
      end if 
  end case
end

on keyUp me
  gMatch = 0
  repeat with x = gUserInput.length down to 1
    if char x of gUserInput  = char x of gAnswerText then
      gMatch = gMatch + 1
    end if
  end repeat
end

on exitFrame me  
  gUserInput = member(gEntryText).text
  gAnswerText = member(gAnswer).text
  if gAnswer = gUserInput then
    if char gKeyCount of gUserInput  = char gKeyCount of gAnswerText and
gMatch = gKeyCount then
      member(gEntryText).color = rgb(0, 0, 255)
    else
      member(gEntryText).color = rgb(0, 0, 0)
    end if
    sprite(the currentSpriteNum + 1).editable = TRUE
  else
    if char gKeyCount of gUserInput  = char gKeyCount of gAnswerText and
gMatch = gKeyCount then
      member(gEntryText).color = rgb(0, 0, 255)
    else
      member(gEntryText).color = rgb(0, 0, 0)
    end if  
  end if
end
__________________________

The problem with this is if I apply it to all 5 answer sprites, the
cursor is planted on the last sprite.  I know this is because of the
exitFrame script, but I am wondering how to alter this so that doesn't
happen.  Any suggestions?  By the way, this works great if the script is
applied to only one sprite.
Sharon Moeller 

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to