Anteworld - Outerra Game > JavaScript development

Properties

(1/3) > >>

SteelRat:
Hi cameni!

Object.getOwnPropertyNames(this)


--- Code: ---...
$ctx   // What is it?

--- End code ---

cameni:
A function that returns the context where the object was created. In theory should allow you to access global properties of the script where the object was created, though it may not be always clear where that was.

SteelRat:

--- Quote from: cameni on June 29, 2015, 11:22:22 am ---A function that returns the context where the object was created. In theory should allow you to access global properties of the script where the object was created, though it may not be always clear where that was.

--- End quote ---

Interesting!


--- Code: ---this.ctx = $ctx(this);

--- End code ---

Correctly?

necro:
no, this might be enough:



--- Code: ---var $ctx;
--- End code ---


You can access the methods easily by

--- Code: ---$ctx.method()
--- End code ---

cameni:
$ctx is defined as a method on interface objects, so:


--- Code: ---var obj = // create object somehow ...
obj.$ctx().something = 1; //sets global variable "something" in the context of the obj's script

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version