The error you're getting is probably because there is a stray pending message that is triggering after you've already moved to the gamePaused card. On that card there is no field but the pending message has been sent already. To clean this up, put the body of the handler that removes all pending messages into a closeCard handler in the script of the gameSelect card. Then it will stop all pending messages whenever you change cards.
If you look at pendingMessages in the dictionary you can see that each pending message is comprised of several items on a line. The first item is an ID number that identifies each message. The ID is required to cancel a message, so that's why the handler cancels "item 1" of each pending message.
That said, there may be a better way to handle this than using the "send" method. As you have it now, I don't see any harm in using "move" as opposed to setting the location of the object when using a "send" structure, but if we switch entirely to the "move" command then you can use built-in messages to handle everything without needing to worry about pending messages at all. If you issue a "move" command with the additional parameter "without waiting", the card will receive a "moveStopped" message after the move completes. You can trap that message, check the location of the field, and either issue another "move" command or bail out. There are no pending messages to worry about using this method. I've changed the amount of the vertical move to only a single pixel to prevent jerkiness:
Code: Select all
on moveObj
if gamerunning is true then
move field "FirstWord" relative 0,1 without waiting
end if
end moveObj
on moveStopped
if the top of field "FirstWord" > the bottom of the card "GameSelect" then
set the bottom of the field "FirstWord" to the top of the card "GameSelect"
else
moveObj
end if
end moveStopped
Assuming your pause button sets gameRunning to false, the moveObj won't do anything after the pause button is clicked so calling it additional times doesn't matter. The moveStopped handler checks the location of the field and only calls moveObj again if the field meets the location criteria.
This seems a cleaner way to manage things than using the somewhat messy "send" method. We need "send" frequently for many things, but in this case there's a built-in way to do it.