Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: found and replaced Scene Graph with SceneGraph (no space)

Table of Contents

Table of Contents

...

Scene Graph SceneGraph applications have data object scoping rules that are similar to traditional programming languages. You have:

  • function scope: objects that can only be accessed within the function in which they were defined
  • component scope: objects that can be accessed anywhere within a component XML file, similar to file scope in traditional programming languages
  • global scope: objects that can be accessed anywhere within a Scene Graph SceneGraph application

These different levels of scoping are identified by the use of the m object reference which can be used to disambiguate and access objects at different levels, similar to the use of m in BrightScript. 

...

There is a special use of the m object reference in Scene Graph SceneGraph for identifying the top of the Scene Graph SceneGraph tree for a component XML file. To do this, use the m.top object reference, which refers to the component itself. For example, to create the dialog object and assign it to the dialog field of a Scene node defined in a component XML file (which is the required usage of the Dialog node class), assign the dialog object to the dialog field using the m.top object reference:

...

Likewise, if you want to use findNode() to find a Scene Graph SceneGraph node object anywhere in the Scene Graph SceneGraph tree for a component XML file, use the m.top reference to start at the top of the tree:

...

  • To declare a data object at global scope, store it in a field or child of the global node. This global node may be accessed from the entire Scene Graph SceneGraph application.
  • To access the global node in components, use the predefined m.global, much like m.top
  • For access to the global node from non-component script as in source/main.brs, use getGlobalNode() called on the roSGScreen object.
  • In non-component script, where the global node is obtained using getGlobalNode(), you can store it in m.global so that the syntax for subsequent references to it matches that for components.

...

You can access and set the fields, or the children nodes, of the global node from anywhere in the Scene Graph SceneGraph application. In the non-component example above, the global node idfield value is set to GlobalNode. Likewise, you can access and set the fields for the global node from components by accessing the component m to get its special global element:

...