Thanks for the follow-up. I think I've tried what you are suggesting, but seem to get the same output. Here is some code to go along with my issue
1) Utility Class - util.brs
I've created a test util.brs as you've suggestion with two sample functions I'd like to use across the app:
function util()
obj = {
printTest: _printTest
getSomething: _getSomething
}
return obj
end function
function _printTest()
print "_printTest()"
end function
function _getSomething()
print "_getSomething()"
end function
2) My SceneGraph Screen - SubscribeScreen.brs
I'm invoking 'util()' in the roSGScreen itself, because it seems that if I attempt to call it in the 'RowListScene' Component Script, then the app crashes with an error:
Function Call Operator ( ) attempted on non-function. (runtime error &he0) in pkg:/components/RowListScene.brs(5)
005: utils = util()
Invoking util() here avoids that error, which makes me assume I would then need to pass it into the Scene using a GlobalNode.
sub SubscribeScreen()
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("RowListScene")
utils = util()
m.global = screen.getGlobalNode()
m.global.id = "GlobalNode"
m.global.addFields( {utils: utils} )
screen.show()
while(true)
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then return
end if
end while
end sub
3) The SceneGraph Component script - RowListScene.brs
function init()
m.top.backgroundURI = "pkg:/images/background.png"
utils = m.global.utils
' utils = util() -- this causes an error when invoked from this file
print utils
...
end function
In turn, when I print out 'utils' up there, that is where I find:
<Component: roAssociativeArray> =
{
getsomething: invalid
printtest: invalid
}
Directly attempting to call utils.getsomething() or utils.printtest() in this file also results in error:
Member function not found in BrightScript Component or interface. (runtime error &hf4) in pkg:/components/RowListScene.brs(7)
007: utils.getsomething()
Does anything stick out as what might be causing the issue? It sounds like you're suggesting I shouldn't need to be using the 'screen.getGlobalNode()' function, is that correct?
Thanks for any help you are able to provide.
-Mikey