Xinf API Reference
Back | Index
class xinf.erno.Runtime
extends SimpleEventDispatcher

DOCME: out of date!

The Runtime class has static functions to request the global Runtime instance (a singleton) and it's associated Renderer.

The Runtime represents the runtime environment (Flash, JavaScript, Xinfinity), there is only one global runtime object for a running Xinf application, an instance of a class deriving from xinf.erno.Runtime. The specific runtimes implement some 'abstract' functions defined here in their individual ways.

The Runtime singleton (Runtime.runtime) is an EventDispatcher that dispatches all global low-level user-interface events. In Xinfony, some of these are listened for and dispatched to the corresponding target object (see xinf.ony.Manager). For other events, you will have to register at the runtime (in particular, this regards MOUSE_UP, MOUSE_MOVED, KEY_UP, KEY_DOWN and STAGE_SCALED). You can register listeners either at the Runtime.runtime member or using the static addEventListener function.

The Runtime is initialized automatically when you instantate an xinf.ony.Application object, or do anything with Runtime.runtime. Only if you want to use Xinferno directly you should probably care about initialization once at the beginning of your application.

function new( ) :Void
function getNextId( ) :Int
return a newly allocated numeric ID for use with xinf.erno.Renderer. The default implementation will throw an exception.
function getDefaultRoot( ) :NativeContainer
return the runtime's default Root NativeContainer. The default implementation will throw an exception.
function run( ) :Void
start the runtime main loop if such exists. From your application, you should call Runtime.runtime.run() once, at the end of your main() (xinf.ony.Application.run() does this for you). The function might return instantly, when the application quits, or never, depending on the runtime environment. The default implementation will throw an exception.
function changed( ) :Void
signal to the Runtime that some content in the display hierarchy has changed. This will trigger re-rendering of the default Root object. There is no need to ever call this if you use Xinfony (the Manager will take care of this). The default implementation does nothing.
function setBackgroundColor( r:Float, g:Float, b:Float, ?a:Float ) :Void
static var runtime :Runtime (read-only)
A reference to the global Runtime singleton. If it is not initialized yet, requesting this will intialize the runtime.
static var renderer :Renderer (read-only)
A reference to the Renderer associated to the global Runtime singleton. If it is not initialized yet, requesting this will intialize the runtime.
static function addEventListener<T>( type:EventKind<T>, h:T -> Void ) :T -> Void
add an event listener to the Runtime singleton. This is a convenience function that has the same effect as Runtime.runtime.addEventListener.
static function removeEventListener<T>( type:EventKind<T>, h:T -> Void ) :Bool
remove an event listener from the Runtime singleton. This is a convenience function that has the same effect as Runtime.runtime.removeEventListener.
Back | Index