if msgType = "roSGScreenEvent" if msg.isScreenClosed() then return end if end while end sub
And am calling it like so:
function showWatchSGScreen(video_key as String) m.sceneTask = CreateObject("roSGNode", "launchSceneTask") m.sceneTask.setField("scene", "watchScene") m.sceneTask.setField("video_key", video_key) m.sceneTask.ObserveField("test_trigger", "testFunction") m.sceneTask.control = "RUN" end function
However, I get the following error:
Interface not a member of BrightScript Component (runtime error &hf3) in ...A2pJLT7/pkg:/components/homeScene.xml(97) 097: m.sceneTask.setField("scene", "watchScene")
The examples in the documentation seem to be doing it exactly this way. Is there a bug, or is this user error?
Where are you calling showWatchSGScreen? You can only create Task nodes in certain contexts (I forget which don't work off the top of my head), so it's probably that m.sceneTask is invalid. You could potentially create the task node during init(), then just set the fields and control to "RUN" in your showWatchSGScreen function.
Right, if you're calling it from Main, then it's running in the main BrightScript context, which doesn't support Task nodes. You should create and configure the Task node in the init() method of your scene, then you should be able to trigger it by setting the control to "RUN" at any point later in execution.