Prev | Current Page 234 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

To
access the value of a property marked as dynamic, it is necessary to provide accessor
methods at run time. The application itself must provide an implementation of the
get/set methods dynamically. This can be done by modifying an object instance or
the prototype of the class at run time using the reflection capabilities of haXe.
The property is defined in this way:
var runtime(dynamic,dynamic) : String;
One or both the accessor methods must be provided dynamically and they must be
named get_runtime and set_runtime (suffix get/set_followed by the property
name), as shown in the following example:
Reflect.setField(objectInstance, ???get_runtime???, function()
{
// do something here and return a string
return ??????;
});
Reflect.setField(objectInstance, ???set_runtime???, function(value)
{
// do something here and return a string
return value;
});
In practice the compiler does not check for the existence of the get_X , set_X methods and, thus they can
be provided at run time by the developer.


Pages:
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246