I just realised that global scope is not the same for the component and channel, GetGlobalAA() differs in the component.
Well, I can deal with that but the libraries.. for example, to load a library (generalUtils.brs, analytics.brs, ...) it's required to insert <script> tag in every xml component. Is there an easier way to do it? Or to access the other scope?
I talked with a Roku engineer about this a couple weeks ago. He confirmed there are 2 threads – 1 for “the old way” and one for the scene graphs. To implement inter-thread communications and access the other threads scope, he said to use a data field observer. As a test-case I set up an observer to monitor the ‘control’ attribute of an Animation node that gets started when the user presses the OK button. I create an observer for the field in both the main thread and the scene-graph thread. The code in Main.brs:
scene = screen.CreateScene("sgTest")
m.animn = scene.findNode("playingAnimation")
and the code in the component XML’s init() function:
m.animn = m.top.findNode("playingAnimation")
When the animation is started, the only observer function triggered is the one in the scene-graph thread. While trying to figure out what is happening, I came across the following in the SDK documentation:
The callback function you write to handle the node field change event must be included in the component <script> element, and manipulate declared objects within the component.
So I’m thinking this is why the main thread’s observer is not invoked, even though I can access the animation’s control field from that thread (which I confirmed via the use of the debugger).