At 12:22 -0500 06/12/2002, Fred Westermeyer wrote:
>This is a job that you have to love to do it.
>
>Here is the code that I think is having the problem.
>
>property pMem, pText
>
>on beginSprite me
> pText = " "
> pMem = sprite(me.SpriteNum).member
> pMem.text = pText
>
>end beginSprite
>
>on acceptInput me, newCharacter
> pText = pText & newCharcater
> pMem.text = pText
>
>end acceptInput
>
>If I change out
>
>on acceptInput me, newCharacter
> pText = newCharcater
> pMem.text = pText
>
>end acceptInput
>
>This will work but on one character only. What am I doing wrong?????
You're not appending the character any more to the pText variable;
rather you're setting pText equal to whatever it was that the user
pressed.
Here's how I would probably do it myself:
on beginSprite me
sprite(me.spriteNum).member.text = ""
END beginSprite
on keyUp me
me.AcceptText ( the key )
END keyUp
on AcceptText me, sKey
if sKey = BACKSPACE then
sprite(me.spriteNum).text = ""
else
pass
end if
END AcceptText
This just checks for the backspace key and nukes the field if it's
hit; otherwise it passes the event as normal. There's no real need
for special setting-up of variables here; for instance the code
sample you sent would have a hard time handling arrow keys.
If course if you want to filter for certian types of keys you can;
you would then do things like keyCode or charToNum tests to allow
certain keys to pass, and to block others. So for instance if you
wanted to let only numbers through, you might do this instead:
on AcceptText me, sKey
if sKey = BACKSPACE then
sprite(me.spriteNum).text = ""
else if "1234567890" contains the key = FALSE then
BEEP
stopEvent
else
pass
end if
END AcceptText
This still uses backsapce to clear the field, but also blocks
non-numerics. There are lots of possible permutations on the idea...
--
Warren Ockrassa | http://www.nightwares.com/
Director help | Free files | Sample chapters | Freelance | Consulting
Author | Director 8.5 Shockwave Studio: A Beginner's Guide
Published by Osborne/McGraw-Hill
http://shop.osborne.com/cgi-bin/osborne/0072195622.html
[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!]