Page 1 of 1

Onload events or openCard

Posted: Mon Aug 06, 2012 6:14 pm
by cusingerBUSCw5N
Does LiveCode have any onload events? I want to load an image from the Internet but I don't want to connect it to a button. I want it to automatically load. I looked at OpenCard - but either that isn't the solution or I am putting OpenCard in the wrong spot - because it doesn't work. I was trying a simple test of putting "bob" in a text field with OpenCard and it didn't work either.

on openCard
put "bob" into field "sample text"
end openCard

Sorry for being so dumb.

Re: Onload events or openCard

Posted: Mon Aug 06, 2012 6:27 pm
by mwieder
Hmmm... Nothing wrong with your openCard handler. I take it "bob" isn't going into the field? And that field exists on the card?
Where did you put the openCard handler? You might try something like this to ensure that it's getting called

Code: Select all

on openCard
  answer "openCard!" && the name of this card
end openCard

Re: Onload events or openCard

Posted: Mon Aug 06, 2012 6:29 pm
by sturgis
You need to make sure that messages are not turned off. (look at the toolbar see if the messages icon to see if messages are enabled or disabled)

Then make sure your script is either in the card script or the stack script. From the dictionary:
Sent to a card right after you go to the card.
So when it is sent to the card, if there is an opencard handler there it will execute. If there is NO opencard handler, the message will go up the message path to the stack and look for a handler there.

If the opencard handler is in an object it will never fire (unless you explicitly send the opencard message to the object yourself)

And of course if the card is already open when you enter the script, since it is already open the script won't fire.

Re: Onload events or openCard

Posted: Mon Aug 06, 2012 6:30 pm
by Klaus
Hi,

the script DOES of course work! :D

Where did you put it?
As the name suggest, best to put it into the CARD script.

Check this great overview about the message hierarchie in LiveCode:
http://www.fourthworld.com/embassy/arti ... _path.html

Or am I misunderstanding you?


Best

Klaus

Re: Onload events or openCard

Posted: Tue Aug 07, 2012 5:40 pm
by cusingerBUSCw5N
It works now. I think one of the problems I have had is that I've been using multiple versions of my application with the same names - without using "File" - "Close and remove from memory". Now that I am being more careful to only have one open at a time, I am having fewer problems.

Thanks

Re: Onload events or openCard

Posted: Tue Aug 07, 2012 6:03 pm
by Klaus
Well... 8)