mobileControl message path

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

mobileControl message path

Post by nextyoyoma » Thu Oct 18, 2012 11:13 pm

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?

Adrian
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 79
Joined: Wed Jul 11, 2012 5:03 pm

Re: mobileControl message path

Post by Adrian » Fri Oct 19, 2012 9:10 am

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

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mobileControl message path

Post by Klaus » Fri Oct 19, 2012 11:00 am

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

nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

Re: mobileControl message path

Post by nextyoyoma » Mon Oct 22, 2012 9:26 pm

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!

Post Reply