The following summarizes how to transition from the older Roku API to Scene Graph applications. In general, Scene Graph handles events without requiring you to write custom event loops, and allows you easily add custom event handlers by observing virtually any of the fields used in your Scene Graph application. Also, Scene Graph supplies built-in node classes that are very similar to some BrightScript UI screen components, but also gives you much greater flexibility to build your own custom screens. Because Scene Graph is more dynamic, flexible, and object-oriented than the older Roku API for building UI elements, you cannot write an equivalent Scene Graph application by simply substituting different function names and argument lists for UI elements.
However, much of your existing BrightScript code that handles other aspects of your application can probably be used in the new context of a Scene Graph application. For example, calls to your existing BrightScript functions can be added to any Scene Graph XML component file, by specifying the location of the BrightScript file in the package components directory in the <script> element. For example, if you had a set of functions to manipulate URLs, you could add the following <script> element to allow a Scene Graph component to call the functions:
<script type = "text/brightscript" uri = "pkg:/components/uriutils.brs" />
If these calls relied on application global data, you would have to set up a global node as described in Global Scope for this data.
There is a simplifying assumption you can make when transitioning an older Roku API application to Scene Graph. In many cases, Scene Graph replaces a series of BrightScript component interface function calls with setting and reading of node class fields of the equivalent parameters. For example, the SetNumPinEntryFields() interface function call for the roPinEntryDialog component is replaced by setting the
pinLength field of the internal PinPad node object of a PinDialog node. But note that for many of the older Roku API screen components, you must develop your own custom screen component equivalent from more fundamental Scene Graph node classes. For example, you must develop an equivalent of the roSearchScreen component using the MiniKeyboard node class as the user input basis of a custom Scene Graph search screen component. You must then write additional BrightScript code to replicate the function of the roSearchScreen component.
|roUniversalControlEvent||Scene Graph supplies a single function that replaces the need to write a remote control input event handling loop.|
|roTimespan||Timer node||Adding a Timer node, observing the |
|BrightScript Component Events||Scene Graph events||You can observe changes in virtually all aspects of Scene Graph operation using the <interface> field |
|roPinEntryDialog||PinDialog node||The function of the PinDialog node is almost identical to the roPinEntryDialog component.|
|roTextScreen||ScrollableText node||These two are very similar in appearance and operation.|
|roFont, roFontRegistry||Font node||The Font node simplifies specifying different fonts.|
|roGridScreen||PosterGrid, MarkupGrid, RowList nodes||The built-in Scene Graph poster grid node classes are simpler, but much more flexible. You can use Scene Graph to create a custom grid screen identical to the older Roku API, but even better, you can create a completely original grid screen of your own design.|
|roImageCanvas, roScreen||Scene Graph||Scene Graph starts with the ability to draw your own custom screen elements, then use them as objects throughout your application.|
|roKeyboardScreen||MiniKeyboard, Keyboard nodes||The keyboard screens and Scene Graph keyboard node classes are very similar in appearance and operation.|
|roListScreen||LabelList, MarkupList, RowList, CheckList, RadioButtonList nodes||Scene Graph gives you many more options and flexibility for list screens.|
|roAudioPlayer||Audio node||The roSpringboardScreen component for user selection of audio files can be created using Scene Graph list and grid node classes.|
|roVideoScreen, roVideoPlayer||Video node||The Scene Graph Video node class encompasses all the functionality of the roVideoScreen and roVideoPlayer components. The roSpringboardScreen component for user selection of video files can be created using Scene Graph list and grid node classes.|
|roSearchScreen||MiniKeyboard node||The MiniKeyboard node class can be used as the user input basis of a custom Scene Graph component equivalent to the roSearchScreen component.|
|roSpringboardScreen||Scene Graph||The roSpringboardScreen component for user selection of audio/video files can be created using Scene Graph list and grid node classes.|