Hi, I'm new to Scene Graph xml. I meet an problem recently, that I create a custom xml component "CustomButton". It works good when I try to create it in init() function, but it cannot be created in onKeyEvent() function. Here is the sample code:
<?xml version="1.0" encoding="utf-8" ?>
<component name="CustomButton" extends="Group">
<children>
<Poster id="background" />
<Poster id="focusBox" />
<Label id="text" />
</children>
</component>
<?xml version="1.0" encoding="utf-8" ?>
<component name="channelListScreen" extends="Group">
<script type="text/brightscript">
<![CDATA[
function init() as Void
a = createObject("roSGNode", "CustomButton")
? a ' a is a roSGNode here
end function
function onKeyEvent(key as String, press as Boolean) as Boolean
a = createObject("roSGNode", "CustomButton")
? a ' a is Invalid here
end function
]]>
</script>
<children>
<Label text="Channel List Screen"/>
</children>
</component>
Anyone could help me? Thanks in advance!