Creating and using intrinsic objects – BrightSign BrightScript 2 Reference Guide User Manual
Page 23

23
Creating and Using Intrinsic Objects
In most of this manual we use the term “object” to refer to a “Roku Object”. These are C
or C++ components with interfaces and member functions that BrightScript uses directly.
Other than a few core objects that BrightScript relies upon (roArray, roAssociativeArray,
roInt, etc.) Roku Objects are platform specific.
You can create “intrinsic” objects in BrightScript itself to use in your scripts. However,
to be clear, these are not Roku Objects. There is currently no way to create a Roku
Object in BrightScript, or to create intrinsic objects that have interfaces (they only
contain member functions, properties, or other objects).
A BrightScript object is built upon an Associative Array. In fact, it is an
roAssociativeArray. When a member function is called “from” an AssociativeArray, a
“this” pointer is set. The “this” pointer is “m”. “m” is accessible inside the FUNCTION
code to access object keys.
A “constructor” in BrightScript is a normal function at global scope that creates the
AssociativeArray and fills in its member functions and properties. There is nothing
“special” about it.
For an example, see the “snake” game at the end of this manual.