Page 1 of 1

mobileControl message path

Posted: Thu Oct 18, 2012 11:13 pm
by nextyoyoma
I am building a simple app to play different videos files based on the time of day (that information is held in a MySQL database). I need to have the app check for what movie it should play as soon as it finishes playing the current video. I have only one stack and one card, no controls other than the one created by mobileControlCreate I was trying to do this with:

Code: Select all

on playerFinished
call setsource
end playerFinished
but I don't know where to put this control structure. If it were a LiveCode control (like a text field) I would edit the control script and put it there, but since this control doesn't exist until created by mobileControlCreate, I can't do that. I thought that if the message wasn't trapped it would go on to the next object in the message path. If that's the case, shouldn't putting this control structure on the card do the trick? For some reason when I do that, it doesn't work.

Obviously I'm missing something fundamental about the way iOS control messages work, or something about the way messages work in general. Can someone enlighten me?

Re: mobileControl message path

Posted: Fri Oct 19, 2012 9:10 am
by Adrian
As per the LiveCode iOS Release Notes, messages are sent to the object that created the iOS native object. For example, if you use a preOpenCard script to mobileControlCreate, then messages will be sent to the Card, so your handlers should be in the card.

Cheers,

Adrian

Re: mobileControl message path

Posted: Fri Oct 19, 2012 11:00 am
by Klaus
Hint:
"call" is only neccessary if the "message" you are "calling" is NOT in the current message path.
You can use it anyway, but with QUOTES!

Code: Select all

on playerFinished
  call "setsource"
end playerFinished
Or simply use:

Code: Select all

on playerFinished
    setsource
end playerFinished
Best

Klaus

Re: mobileControl message path

Posted: Mon Oct 22, 2012 9:26 pm
by nextyoyoma
Thanks to both of you for the helpful info. The problem actually turned out to be that the message was being sent and received, but another part of my script (taken from a tutorial) did not work. The tutorial said to use "controlDelete" to delete the player before recreating it instead of "mobileControlDelete." Didn't catch it because I didn't think to debug the tutorial! Lesson learned!