Hi All,
I'm building a little library-like bit of code to do my http gets and what not. I'd like to use callbacks to notify my object when things are finished.
Let's say I had a button that called my library:
on mouseUp
httpGet "url", "httpFinished"
end mouseUp
on httpFinished
answer "Wa-hey, I made it!"
end httpFinished
How does my library know where it could find the 'httpFinished' handler?
I didn't see anything in the User Guide about this, nor the lessons. Anyone got a FM to RT?
-Ken
Libraries and Sending output back to my caller...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Libraries and Sending output back to my caller...
Off the top of my head, since you've got httpGet in a mouseUp handler I'll assume that httpGet is asynchronous. Otherwise you'd be better off saying
but with that out of the way, how about something at the end of httpGet like
Code: Select all
dispatch "httpGet" with url,"httpFinished"
Code: Select all
send "httpFinished" to the target
Re: Libraries and Sending output back to my caller...
Hiya,
Hrm...seems that the 'target' is getting lost in all the callbacks. the short name of 'target' is the name of the card upon which the script lies, not the button that originally kicked it off. Might need some sort of closure to keep the state of 'target' around.
Ah, that's the key then...if I save the 'target' in the first call, after all the callbacks I can send the callback message to the object originally clicked on.
Well done! Thanks for the pointer there.
-Ken
Hrm...seems that the 'target' is getting lost in all the callbacks. the short name of 'target' is the name of the card upon which the script lies, not the button that originally kicked it off. Might need some sort of closure to keep the state of 'target' around.
Ah, that's the key then...if I save the 'target' in the first call, after all the callbacks I can send the callback message to the object originally clicked on.
Well done! Thanks for the pointer there.
-Ken